![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The long && and || condition , I broken down the part to many chained if statement . I also tried using MarketInfo(OrderSymbol() , MODE_ASK/BID) instead of OrderClosePrice() .
This part still sometimes worked and not all the time , I also tried those suggestion you all gave me but it still ended up the same .
I'm not sure whether is it this that cause' the problem or is it something else . But out of those trial and error this is what I notice .
Looks like always the most bottom part of the opened order didn't wanna move the stop loss EVEN if the condition is met ( The long && and || condition and the many chained if statement , I tried both ) .
The EA settings :
Account 1 before :
Account 1 after :
For this account 1 , 1st and 2nd order did not meet the if condition/if + && and || condition , so stop loss is not moved ( which is correct ) .
The 3rd order however , already met the condition and it should trail up to the 10th one , but stop loss was only moved ONCE . ( wrong wrong wrong )
It should have move more than once ( should be 50.0 pips by my count , not 5.0 pips ) .
Account 2 before :
Account 2 after :
For this account 2 , only the 1st order didn't meet the condition , so again no stop loss is moved ( which is correct ) . The 2nd and 3rd order met the condition and HERE'S THE WEIRD PART .
The 2nd order trail exactly up to the 10th one , stop loss was moved exactly 10 times . Stop loss moved to a 50.0 pips from that individual order's open price ( which is correct ) .
The 3rd order however also met the condition and it should trail up to the 3rd one , but again stop loss was only moved ONCE . ( wrong again :( )
Did you all notice that both of the account where the trailing part doesn't work properly is at the last order ?
If the USDJPY can worked , it should be able to applied to all the other pairs . I'm not sure what to do with it .
I use a count back for loop that I read where RaptorUK taught should be good though . Counting backwards shouldn't be the problem either .
Experts tab didn't show any errors either ....
@.@ T_T
I see what you mean now, I didn't read the trade results correctly the first time
I tried , still the same ffoorr ....
I tried it lots of times , it is still always the last order that didn't get modify properly .... Count down for loop cause this problem ? I don't think so though but I don't know why is it not working properly ...
juniorlcq:
Count down for loop cause this problem ?
it doesn't matter if you count up or down (trailing stoploss)
deleting or closing a trade you must to count down
I tried counting upwards too , same problem still .
Is it the 2nd for loop already modify the order and I had to reselect again ?
At first I selected the order , and at the 2nd for loop the condition met it modify that order . Do I need to reselect again ?
OrderSelect
The OrderSelect() function copies order data into program environment and all further calls of OrderClosePrice(), OrderCloseTime(), OrderComment(), OrderCommission(), OrderExpiration(), OrderLots(), OrderMagicNumber(), OrderOpenPrice(), OrderOpenTime(), OrderPrint(), OrderProfit(), OrderStopLoss(), OrderSwap(), OrderSymbol(), OrderTakeProfit(), OrderTicket(), OrderType() functions return the data, copied earlier. It means that in some cases the order details (open price, SL/TP levels or expiration date) may change and the data become non-actual. It is strongly recommended to call the OrderSelect() function before request the order data.