-
double initialPrice; //open price of the first open order double stepInPoint; //distance pips from initial price (value in price). let's say the distance is 20 points double StopLossPrice; double TakeProfitPrice; double stoplossStart; //stoploss of the first open order(value in price)
These variables have random values, or you set them with code you do not show.
-
NormalizeDouble(stoplossStart+=trailStopStep,Digits); //40 points would be added to the last stoploss and make it as stoploss value.
For every time you call UpdateAllOpenOrders, for every order on the current symbol, you increment stoplossStart. Your variable is meaningless.

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
Hi I tried to modify all open orders using this code,
the idea of this stoploss is when price moves up or down more than a certain distance I want the stoploss to change to a certain distance. The initialPrice and stoplossStart would be updated as the price moving in a direction of the open orders. With code above only the first open order that is modified and the rest is not. Anyone can help me fix this problem?