My NT8 strategy works great on ninjatrader sim account.
- Behavior on sim (good): When trade is opened, it has a 20 tick stop loss. If price moves into some loss, then into profit enough to trigger my breakeven, the stop loss is moved to breakeven.
- Behavior on tradovate demo (bad): When trade is opened, it has a 20 tick stop loss. If price moves into some loss, then back in the right direction, it seems like the stop is trailed right behind the price, and if it moves back in the wrong direction even 1 tick, the order is closed and I hear "stop filled" from ninjatrader even though the stop was several points away.
- On NT sim account, if a trade is opened and moves into loss, the trade is ONLY closed if it hits the stop loss 20 ticks away.
- On tradovate accounts, if a trade is opened and moves into some loss, the trade is closed as soon as it starts moving back in the right direction and ninjatrader says "stop filled" even though the stop didn't appear to trail on the chart, and it was quite far away.
I disabled trailing stop setting in my strategy, and this no longer happens. So something is wrong in my trailing stop management, which is causing the issue on Tradovate accounts only.
Relevant code is below. Please let me know if I need to provide more information.
private void ManageTrailingStop(double currentPrice)
{
if (Position.MarketPosition == MarketPosition.Flat)
{
Print($"[{Time[0]}] ManageTrailingStop: Position is flat. Not managing trailing stop.");
return;
}
double currentStopPrice = GetCurrentStopPrice();
Print($"[{Time[0]}] ManageTrailingStop - Current price: {currentPrice}, Current stop: {currentStopPrice}, Position: {Position.MarketPosition}");
if (Position.MarketPosition == MarketPosition.Long)
{
double potentialNewStop = currentPrice - TrailingStopTicks * TickSize;
if (potentialNewStop > currentStopPrice)
{
UpdateStopLoss(potentialNewStop);
Print($"[{Time[0]}] Updated long trailing stop from {currentStopPrice} to {potentialNewStop}");
}
else
{
Print($"[{Time[0]}] Long trailing stop not updated. Potential: {potentialNewStop}, Current: {currentStopPrice}");
}
}
else // Short position
{
double potentialNewStop = currentPrice + TrailingStopTicks * TickSize;
if (potentialNewStop < currentStopPrice)
{
UpdateStopLoss(potentialNewStop);
Print($"[{Time[0]}] Updated short trailing stop from {currentStopPrice} to {potentialNewStop}");
}
else
{
Print($"[{Time[0]}] Short trailing stop not updated. Potential: {potentialNewStop}, Current: {currentStopPrice}");
}
}
}

Comment