I am trying to create an indicator and part of the code requires reading the RSI value xx bars ago. I have the following code(below) but somehow when I try to debug it in the output window, the script doesn't seem to run past the initial section where I check to ensure there's enough bars on the chart
-----------------------------------------------
#region Variables
#endregion
protected override void Initialize() {
CalculateOnBarClose = false;
Overlay = false;
PriceTypeSupported = true;
}
/// Called on each bar update event (incoming tick)
protected override void OnBarUpdate() {
//Check to ensure there's enough bars on the chart
if(CurrentBar < 1)
{
Print("Not enough Bars");
return;
}
//Read the RSI value 10 bars ago
double RSI10 = RSIFunc(10);
Print(RSI10.ToString()); //prints to output window
}
private double RSIFunc(int Shift) {
double RSIValue = RSI(Close, 14, 1)[Shift];
return(RSIValue);
}
#region Properties
#endregion
-----------------------------------------------
Please Help. Thanks in advance
Comment