I am trying to setup a simple strategy that draws a diamond on the chart when price touches a certain moving average.
I would like to apply that strategy to imported historical data.
I have used the strategy wizard, that generates the following code:
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class Touched800 : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#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()
{
Add(SMA(800));
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (GetCurrentBid() == SMA(800)[0])
{
DrawDiamond("800 touched" + CurrentBar, false, 0, 0, Color.Red);
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}
when I run the strategy in the strategy analyzer, nothing happens (I see the chart, but no diamonds...).
Could you help me to understand what is missing?
thank you,
John.
Comment