Can someone help me if I'm missing anything? Attachment shows order placement for buy and close.
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
TimeInForce = TimeInForce.Gtc;
IsExitOnSessionCloseStrategy = true;
Calculate = Calculate.OnBarClose;
ExitOnSessionCloseSeconds = 30;
OrderFillResolution = OrderFillResolution.Standard;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
// This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = false;
}
}
protected override void OnBarUpdate()
{
if (CrossAbove(MACD(12, 26, 9).Diff, 0, 1))
{
EnterLong(1, "Buy");
}
if ((CrossBelow(MACD(Close, 12, 26, 9).Diff, 0, 1))
&& (Position.MarketPosition == MarketPosition.Long))
{
ExitLong(1);
}
}

Comment