Well its not quite there yet. Attached two photos... one of the strat executing the ATM and one of the strat executing draw arrow. There are four instances where the strat with the ATM "missed" buy signals and one instance where it did a "buy" when it should not have.
When those two strats run live against incoming data, the indicators look exactly the same.
In a way it was good to be out of some of that chop... I just need to figure out why the code does not work the same between both strats.
Go Long ATM:
// ATM Strategy code cut-and-paste from NT
// Make sure this strategy does not execute against historical data
// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'ES 2 w BE and Trail' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
// in the line below I've deleted && Close > Open from the default sampleATMstrategy code
if (orderId.Length == 0 && atmStrategyId.Length == 0 )
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "ES 2 w BE and Trail", atmStrategyId);
// Check for a pending entry order
if (orderId.Length > 0)
string status = GetAtmStrategyEntryOrderStatus(orderId);
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status);
Print("The entry order filled amount is: " + status);
Print("The entry order order state is: " + status);
// If the order state is terminal, reset the order id value
if (status == "Filled" || status == "Cancelled" || status == "Rejected")
orderId = string.Empty;
} // If the strategy has terminated reset the strategy id
elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;
if (atmStrategyId.Length > 0)
// You can change the stop price
if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
AtmStrategyChangeStopTarget(0, Low - 3 * TickSize, "STOP1", atmStrategyId);
// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtm
1. Compare each strat's code once again, line by line.
2. Run both on the same chart using Market Replay 1x speed.
3. Work on hard coding an "ATM like" exit strategy as Mike suggested weeks ago . I've started that already on a strat I use on FESX, but struggling with how to "tighten" stops after trailing for a while.
It's 9am where I live, which gives me 5 hours until FESX opens. Let the Games begin!
Just to update this thread. My problem was solved with Action #1 above. A single typo in my strat code had it trading against an indicator parameter that was different than the plotted parameter.
I've found the bug, and it was me.
On the ATM-like hard code, I'm still playing around with it. To be honest the only reason for it seems to be the issue of backtesting using data from different time frames. Important, but I need to prioritize what I need to do in NT.