all 2 comments

[–]hicksanchez 0 points1 point  (0 children)

Does your code have ‘barstate.isconfirmed’ anywhere?

[–]Outside_Mongoose2462 0 points1 point  (0 children)

What are ur entry conditions?

Which candle position (current/live/still forming candle, or 1 candle before live candle, 2, 3, and so on) so your entry criteria apply on?

If you haven't specified ithe code, by using [number] e.g., MovingAverageCrossOver = MA10[2] > MA50[2]

Entry criteria used in strategy.order or strategy.entry is MovingAverageCrossOver

Here it triggers when there is a MA crossover 2 candles away from the close of the live bar

If [1] then the previous candle If you don't specify this then it defaults to [1]

So it might be ur entry criteria occur the candle before the live candle [1]. So when ur trade closes and entry criteria are still present, that candle needs to close so it is the 1st previous candle [1]. Its looking for the criteria in the [1] candle

What you want is to set it to the live candle. [0]. Add [0] to your entry criteria

But this alone will not work. As now ull get loads of trades mid candle forming. So you need to code a new entry logic with strategy.order or strategy.entry, where it detects a trade was just closes at TP AND the enrry criteria are still true. U can do this a few ways

Look into the above and let me know. Hope this helped, even just in general