In NT 7 in a strategy it was simple to compare historical data of indicator to current data for example:
--------------------------------------
if(SMA(14)[0] < SMA(14)[1]
{
BarColor = Color.Red;
}
--------------------------------------
In NT 8 I am trying to replicate the strategy but I am having no luck, the code compile but when I enable the strategy it disable itself right away
--------------------------------------
namespace NinjaTrader.NinjaScript.Strategies
{
public class Testing : Strategy
{
private SMA SMA1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "Testing";
Calculate = Calculate.OnPriceChange;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = false;
}
else if (State == State.Configure)
{
SMA1 = SMA(14);
}
}
protected override void OnBarUpdate()
{
// Set 1
if (SMA1[0] <= SMA1[1])
{
BarBrush = new SolidColorBrush(Colors.Red);
}
}
}
}
Comment