using System;
public class TMsignal_RSI_Divergence_V1_0
{
public double RsiDivergence(int rsiPeriod, double[] source, int pivotRight, int pivotLeft, int rangeMax, int rangeMin, bool showBull, bool showHiddenBull, bool showBear, bool showHiddenBear)
{
int len = rsiPeriod;
double[] src = source;
int lbR = pivotRight;
int lbL = pivotLeft;
int rangeUpper = rangeMax;
int rangeLower = rangeMin;
bool plotBull = showBull;
bool plotHiddenBull = showHiddenBull;
bool plotBear = showBear;
bool plotHiddenBear = showHiddenBear;
// Define Colors
string bearColor = "black";
string bullColor = "blue";
string hiddenBullColor = "green";
string hiddenBearColor = "red";
string textColor = "white";
string noneColor = "white";
double[] osc = Rsi(src, len);
// Plot RSI
Plot(osc, "RSI", 2, "#1522b0");
HLine(50, "Middle Line", 1, 1, 2);
HLine(80, "Overbought", 1, 2, 2);
HLine(20, "Oversold", 1, 3, 2);
Fill(80, 20, "Background", "blue", 90);
bool[] plFound = new bool[osc.Length];
bool[] phFound = new bool[osc.Length];
for (int i = lbL; i < osc.Length; i++)
{
plFound[i] = PivotLow(osc, lbL, lbR, i);
phFound[i] = PivotHigh(osc, lbL, lbR, i);
}
bool InRange(bool cond)
{
int bars = BarsSince(cond);
return rangeLower <= bars && bars <= rangeUpper;
}
// Regular Bullish
bool oscHL = osc[lbR] > ValueWhen(plFound, osc[lbR], 1) && InRange(plFound[1]);
bool priceLL = Low[lbR] < ValueWhen(plFound, Low[lbR], 1);
bool bullCond = plotBull && priceLL && oscHL && plFound;
Plot(plFound ? osc[lbR] : double.NaN, -lbR, "Regular Bullish", 2, bullCond ? bullColor : noneColor, 0);
PlotShape(bullCond ? osc[lbR] : double.NaN, -lbR, "Regular Bullish Label", Text("Bull"), Shape.LabelUp, textColor, bullColor, 0);
// Hidden Bullish
bool oscLL = osc[lbR] < ValueWhen(plFound, osc[lbR], 1) && InRange(plFound[1]);
bool priceHL = Low[lbR] > ValueWhen(plFound, Low[lbR], 1);
bool hiddenBullCond = plotHiddenBull && priceHL && oscLL && plFound;
Plot(plFound ? osc[lbR] : double.NaN, -lbR, "Hidden Bullish", 2, hiddenBullCond ? hiddenBullColor : noneColor, 0);
PlotShape(hiddenBullCond ? osc[lbR] : double
Bu kodda parantes hatası alıyorum ve bunu taramaya çevirebilir miyiz teşekkürler.