I created an indicator draws two lines on the price chart that follow the movement of the RSI indicator. One line draws when the RSI is up and the other when the RSI is down. For some reason when the "up" side line is called I get "out of range" error, but only on the "up line". If I run the "down line by itself everything is fine. Here is the code. I have "if (CurrentBar < 20) return;" I can change the numerical value, but the error always occurs on the bar after the numerical value. Can someone give me and idea of why this is happening?
if (CurrentBar < 20) return; //low if(Close[1] < Close[2] && Close[2] < Close[3] && (Close[0] > Close[1] || Close[0] == Close [1])) { if(Finding_Valleys(RSI(14,3)[2],RSI(14,3)[1],RSI(14,3)[0]))//Captures the low point { DrawDiamond("RSI Valley " + CurrentBar, true, 1 , Low[0] - .03, Color.Magenta); rsi_low_value = RSI(14,3)[1]; rsi_low = CurrentBar; DrawLine("RSI line Down " + CurrentBar, true, CurrentBar - (rsi_high - 1) , High[CurrentBar - (rsi_high - 1)], CurrentBar - (rsi_low - 1), Low[CurrentBar - (rsi_low - 1)], Color.Red, DashStyle.Solid, 2); Print(Time[0] + " Low " + rsi_low_value ); } } //high if(Close[1] > Close[2] && Close[2] > Close[3] && (Close[0] < Close[1] || Close[0] == Close [1])) { if(Finding_Peaks(RSI(14,3)[2],RSI(14,3)[1],RSI(14,3)[0]))//Captures the high point { DrawDiamond("RSI Peak " + CurrentBar, true, 1 , High[0] + .03, Color.MediumTurquoise); rsi_high_value = RSI(14,3)[1]; rsi_high = CurrentBar; DrawLine("RSI line Up " + CurrentBar, true, CurrentBar - (rsi_low - 1) , Low[CurrentBar - (rsi_low - 1)], CurrentBar - (rsi_low - 1), High[CurrentBar - (rsi_low - 1)], Color.Blue, DashStyle.Solid, 2); Print(Time[0] + " High " + rsi_high_value ); } }
Comment