Don't forget to normalize prices and compare normalized prices always.
A lot of times i seen problems comparing not normalized prices even if they "looks the same", actually there were not.
In addition to this, you also need to checkStop Levels of the symbol on which the position belong and also compare the new SL/TP with bid/ask price (depending on the position type if buy or sell).
Not doing a correct error handling for this thing means to risk to have EA sending a lot of bad requests to broker that will put your account into hyperactive and then disable autotrading on that. Pay attention.
In addition to this, you also need tocheckStop Levelsof the symbol on which the position belong and also compare the new SL/TP with bid/ask price (depending on theposition typeif buy or sell).
yes, I put Ask & Bid as bandwidth for TP's and SL's.
Not doing a correct error handling for this thing means to risk to have EA sending a lot of bad requests to broker that will put your account into hyperactive and then disable autotrading on that. Pay attention.
I already run this EA and a testing duration on a demo account with five symbols
any way, I will try your devices about normalizing my values and Iappreciate that.
Don't forget to normalize prices and compare normalized prices always.
A lot of times i seen problems comparing not normalized prices even if they "looks the same", actually there were not.
In addition to this, you also need to checkStop Levels of the symbol on which the position belong and also compare the new SL/TP with bid/ask price (depending on the position type if buy or sell).
Not doing a correct error handling for this thing means to risk to have EA sending a lot of bad requests to broker that will put your account into hyperactive and then disable autotrading on that. Pay attention.
I tried this code:
if ( TPBuy != PositionGetDouble (POSITION_TP) ) ModifyBuy (SymbArray,PositionGetDouble (POSITION_SL),TPBuy);
I put the same method for TPSell, SLBuy and SLSell (sometimes I change TP only or SL only)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Don't forget to normalize prices and compare normalized prices always.
A lot of times i seen problems comparing not normalized prices even if they "looks the same", actually there were not.
In addition to this, you also need to check Stop Levels of the symbol on which the position belong and also compare the new SL/TP with bid/ask price (depending on the position type if buy or sell).
Not doing a correct error handling for this thing means to risk to have EA sending a lot of bad requests to broker that will put your account into hyperactive and then disable autotrading on that. Pay attention.
I did that for 4 prices
TPbuy changes ---> modify TPBuy
TPSell Changes ---> modify TPSell
SLBuy Changes ---> modify SLBuy
SLSell Changes ---> modify SLSell
Don't forget to normalize prices and compare normalized prices always.
A lot of times i seen problems comparing not normalized prices even if they "looks the same", actually there were not.
I think you're right, comparing between non-normalized with real price will give different values but will be the same after modification.
In addition to this, you also need to check Stop Levels of the symbol on which the position belong and also compare the new SL/TP with bid/ask price (depending on the position type if buy or sell).
yes, I put Ask & Bid as bandwidth for TP's and SL's.
Not doing a correct error handling for this thing means to risk to have EA sending a lot of bad requests to broker that will put your account into hyperactive and then disable autotrading on that. Pay attention.
I already run this EA and a testing duration on a demo account with five symbols
any way, I will try your devices about normalizing my values and I appreciate that.
Thank you
Don't forget to normalize prices and compare normalized prices always.
A lot of times i seen problems comparing not normalized prices even if they "looks the same", actually there were not.
In addition to this, you also need to check Stop Levels of the symbol on which the position belong and also compare the new SL/TP with bid/ask price (depending on the position type if buy or sell).
Not doing a correct error handling for this thing means to risk to have EA sending a lot of bad requests to broker that will put your account into hyperactive and then disable autotrading on that. Pay attention.
I tried this code:
I put the same method for TPSell, SLBuy and SLSell (sometimes I change TP only or SL only)
and:
while SLBuy, SLSell, TPBuy, SLSell, Ask and Bid are normalized double after calculation values
Wihle:
and the same with ModifySell
but the result is:
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:00 failed modify #6 sell 0.01 EURUSD sl: 1.23615, tp: 1.22465 -> sl: 1.23485, tp: 1.22468 [Market closed]
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:00 CTrade::OrderSend: modify position #6 EURUSD (sl: 1.23485, tp: 1.22468) [market closed]
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:20 failed modify #6 sell 0.01 EURUSD sl: 1.23615, tp: 1.22465 -> sl: 1.23485, tp: 1.22468 [Market closed]
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:20 CTrade::OrderSend: modify position #6 EURUSD (sl: 1.23485, tp: 1.22468) [market closed]
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:40 failed modify #6 sell 0.01 EURUSD sl: 1.23615, tp: 1.22465 -> sl: 1.23435, tp: 1.22468 [Invalid stops]
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:40 CTrade::OrderSend: modify position #6 EURUSD (sl: 1.23435, tp: 1.22468) [invalid stops]
2022.01.25 04:30:32.395 Core 1 2021.01.05 00:00:59 failed modify #6 sell 0.01 EURUSD sl: 1.23615, tp: 1.22465 -> sl: 1.23451, tp: 1.22468 [Invalid stops]
EDIT:
Ohh, I am sorry, I mistakenly read the tp value wrong...
Therefore, I cannot help you with the issue. I will pass on this....
EDIT:
Ohh, I am sorry, I mistakenly read the tp value wrong...
Therefore, I cannot help you with the issue. I will pass on this....
Thank you.