I am trying to take longs on the 60 when weekly and daily are close > open and shorts when weekly and daily are close < open but can't get the data series to load.
What am i doing wrong?
namespace NinjaTrader.NinjaScript.Strategies
{
public class Test123 : Strategy
{
private int numberOfTimeframes = 5;
/*
##################################################################################################################
State Changes
##################################################################################################################
*/
#region State Changes
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
//Strategy defaults
Description = @"Multi-timeframe strategy to check if current price is above or below the open of the current candle on added timeframes.";
Name = "Test123";
Calculate = Calculate.OnPriceChange;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = true;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Tick, 1);
AddDataSeries(BarsPeriodType.Minute, 30);
AddDataSeries(BarsPeriodType.Week, 1);
AddDataSeries(BarsPeriodType.Day, 1);
AddDataSeries(BarsPeriodType.Minute, 240);
}
}
#endregion
/*
##################################################################################################################
On Bar Update
##################################################################################################################
*/
#region On Bar Update
protected override void OnBarUpdate()
{
// Ensure enough bars for all data series
for (int i = 0; i <= numberOfTimeframes; i++)
{
if (CurrentBars[i] < 2)
Print($"Not enough bars for series {i}");
return;
}
if (BarsInProgress == 0)
{
}
}
#endregion
}
}

Comment