cbot TP SL are different from the initial calculation

Created at 17 Aug 2022, 11:04
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!
NO

noolohp

Joined 11.03.2022

cbot TP SL are different from the initial calculation
17 Aug 2022, 11:04


Hi,

Is it normal that the cbot set tp and sl slightly different from the calculation ? I printed the calculation of tp and sl each time cbot places a trade yet the tp and sl value in log and event shows slight differences in value ( as of I found , ranging from like 0.01 - 0.1 in xauusd) where each time the differences in tp and sl show the same value. For instance, if tp is set at + 0.1 different from the calculation, sl will also show +0.1 too. Here are the code I'm using:

 

 

 


@noolohp
Replies

PanagiotisCharalampous
17 Aug 2022, 11:26

Hi noolohp,

I cannot buid this code in order to run it and understand what you are looking at. Can you please provise some code that we can run? Also can you share some screenshots showing the problem you are mentioning?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

noolohp
17 Aug 2022, 20:08 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi noolohp,

I cannot buid this code in order to run it and understand what you are looking at. Can you please provise some code that we can run? Also can you share some screenshots showing the problem you are mentioning?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi PanagiotisCharalampous,

Thanks for the reply. Here are some usable code which replicate the mentioned problem and some screenshots.

 

 


@noolohp

PanagiotisCharalampous
18 Aug 2022, 08:47

Hi noolohp,

Your problem is here

You assume that the Bars.Last(1).Close will be the same as the entry price but it is not. You should calculate your SL based on the position's entry price.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

noolohp
18 Aug 2022, 11:39 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi noolohp,

Your problem is here

You assume that the Bars.Last(1).Close will be the same as the entry price but it is not. You should calculate your SL based on the position's entry price.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Thank you PanagiotisCharalampous, I will work on that.


@noolohp