Can't create an order with ATM

I’m using this method to execute an order

private void ExecuteTrade(bool isLong)
{
    double stopLoss;
    double profitTarget;

    if (isLong)
    {
        stopLoss = wickExtreme - (2 * TickSize);
        double risk = Close[0] - stopLoss;
        profitTarget = Close[0] + (risk * RiskRewardRatio);

        EnterLong(Quantity, "ex_1");
        SetStopLoss("ex1", CalculationMode.Price, stopLoss, false);
        SetProfitTarget("ex1", CalculationMode.Price, profitTarget);
        Draw.ArrowUp(this, "LongEntry_" + CurrentBar.ToString(), true, 0, Low[0] - (2 * TickSize), Brushes.Green);
    }
    else
    {
        stopLoss = wickExtreme + (2 * TickSize);
        double risk = stopLoss - Close[0];
        profitTarget = Close[0] - (risk * RiskRewardRatio);

        EnterShort(Quantity, "ex_2");
        SetStopLoss("ex2", CalculationMode.Price, stopLoss, false);
        SetProfitTarget("ex2", CalculationMode.Price, profitTarget);
        Draw.ArrowDown(this, "ShortEntry_" + CurrentBar.ToString(), true, 0, High[0] + (2 * TickSize), Brushes.Red);
    }

    totalTrades++;
    Print("Trade executed: " + (isLong ? "LONG" : "SHORT") + " at " + Close[0] + " | Stop: " + stopLoss + " | Target: " + profitTarget);
}

The problem is that I’ve mess with something because I wanted to create like a 1:2 ratio, but something is wrong, but then I thought, ok if I already have an ATM with the correct StopLoss/Target and contracts, why can’t I use this instead? But I don’t know how to implement it here on my code, can anyone help me out?

That’s not how you access the ATM. Note that if you want to backtest, then you will also need an option to select between ATM and the strategy. For example, I use the ATM, but I can also backtest with the strategy. order-flow-bot/NinjaTrader/Custom/AddOns/OrderFlowBot/OrderFlowBot.StrategyManager.cs at main · WaleeTheRobot/order-flow-bot · GitHub

Yes, I forgot to mention, this strategy now I’m testing it in Playback, but in a future I want it to compile it in LIve sessions, how can I adapt the code for this?

What do you mean adapt the code for live sessions? It should work as long as you enable the strategy regardless if it’s backtesting or with live data.

I checked and figured it out why it was not working, I was using CalculationMode.Price instead of CalculationMode.Ticks, this made the trick, the thing is still this adds 1 contract, but how’s the way I can use an ATM already created let’s say it’s called MyNewATM that is already configured by a target and stopLoss in ticks?

You can do something like this in the main partial class I have. order-flow-bot/NinjaTrader/Custom/AddOns/OrderFlowBot/OrderFlowBot.cs at main · WaleeTheRobot/order-flow-bot · GitHub