This is what I like to have as a strategy:
Buy when the sum from last 5 bars of RSI 2 period is below 35.
I have coded this:
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
private DataSeries myDataSeries;
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
myDataSeries = new DataSeries(RSI(2,1));
Add(RSI(2, 1));
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (SUM(myDataSeries, 5)[0] < 35)
{
EnterLong(DefaultQuantity, "L1of2");
}
// EXIT LONGS
if (Close[0] > SMA(5)[0])
{
ExitLong("EXIT", "");
}
}
Do you know what I'm doing wrong? thanks!

Comment