Stop Loss OnBar, Backtesting vs Live

Created at 28 Dec 2023, 17:47
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ED

edubecerra

Joined 28.12.2023

Stop Loss OnBar, Backtesting vs Live
28 Dec 2023, 17:47


Hi, I have a doubt regarding how backtesting works compered to live. 

When i set a stopp loss for instance on a 2h timeframe, and i run a backtest, i see that the stop loss only triggers when a new bar is created (every 2h). However, if i put the same robot live, the stop loss triggers on tick.

I would like to have control over it, specificaly i want my stop loss to trigger only when a new bar is created, like it does in backtesting.

I have tried using Ontimer() every 2h instead of OnBar() but it doesnt give the same result, which gets me even more confused. I dont get the logic behind.

It would be nice to have a document explaining this kind of differences between backtesting and live trading. If it exists please let me know.

Thank you.


@edubecerra
Replies

PanagiotisCharalampous
29 Dec 2023, 06:07

Hi there,

Make sure you use tick data for your backtesting

Best regards,

Panagiotis


@PanagiotisCharalampous

edubecerra
29 Dec 2023, 09:48 ( Updated at: 30 Dec 2023, 07:09 )

RE: Stop Loss OnBar, Backtesting vs Live

Thanks for your answer but that's not what i meant. I want to know if there's a way to trigger the stop loss or the take profit only on bar formation and not on tick when I run the bot live.

 

 


@edubecerra

PanagiotisCharalampous
30 Dec 2023, 07:11

RE: RE: Stop Loss OnBar, Backtesting vs Live

edubecerra said: 

Thanks for your answer but that's not what i meant. I want to know if there's a way to trigger the stop loss or the take profit only on bar formation and not on tick when I run the bot live.

 

 

No, you would need program such a custom functionality yourself. Stop losses and take profits are actually pending orders with are triggered when the price is reached


@PanagiotisCharalampous