in strategy builder I am trying to do very simple thing. When price cross above the indicator SWING, enter long position. (but enter not on bar close but enter on intrabar basis = as soon as the price crosses the swing)
I have been reading the forum about the granular resolution data series issue, adjusted the code as written (I am not programmer), but the problem is still there.
If i do the historical data backtest, this error still occures: high order fill resolution is only available for single series strategies. For multi-series......
Could you please review my simple code, I believe for you it is matter of few seconds. Thank you very much. Regards Radomir
namespace NinjaTrader.NinjaScript.Strategies
{
public class swing3 : Strategy
{
private Swing Swing1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "swing3";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.High;
OrderFillResolutionType = BarsPeriodType.Minute;
OrderFillResolutionValue = 1;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddDataSeries("NQ 09-19", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Bid);
}
else if (State == State.DataLoaded)
{
Swing1 = Swing(Close, 3);
SetProfitTarget("", CalculationMode.Ticks, 20);
SetStopLoss("", CalculationMode.Ticks, 20, false);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (CrossAbove(GetCurrentBid(0), Swing1.SwingHigh, 1))
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
}
}
}
}