https://www.mql5.com/en/job
//-------------------------------------------------------------------------------------------------Auto Adjust Stop Loss void AutoAdjustStopLoss() { //-------------------------------------------------------------------------------------------------Risk Management double ATR=iATR(Symbol(),0,atrperiod,1); double SL = NormalizeDouble(ATR * 2,Digits); double TP = NormalizeDouble(ATR * atrmultiplier,Digits); //-------------------------------------------------------------------------------------------------+++++ for(int cnt=0; cnt<OrdersTotal(); cnt++) { if(OrderSelect(cnt,SELECT_BY_POS)) if(OrderType()==OP_BUY) if(Ask-SL>OrderStopLoss()) { if(OrderModify(OrderTicket(),OrderOpenPrice(),Ask-SL,OrderTakeProfit(),0)) Alert("Auto Buy SL Error Occured : "+ErrorDescription(GetLastError())); } if(OrderType()==OP_SELL) if(Bid+SL<OrderStopLoss()) { if(OrderModify(OrderTicket(),OrderOpenPrice(),Bid+SL,OrderTakeProfit(),0)) Alert("Auto Sell SL Error Occured : "+ErrorDescription(GetLastError())); } } } //-------------------------------------------------------------------------------------------------End Auto Adjust Stop Loss
i have a function that does the same and uses the ATR for setting the stops.
it moves the stoploss with every profitable tick at a per defined distance.
hope it helps
good luck
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
Hello people,
I need help with the making of a simple program with MetaEditor. The program is simple: it should make an order (for exaxt time) and also move the stop lose line along with the price of the current product. For example i want to make an order to buy 10000 euroes (EUR/BGN) at 19:00 (now is 12:53), and also
if the price is 1.000 and the stop loss is at 0.990, if the price moves up to 1.020 then the stop loss should also move to 1.010. Thank You for the help.