Need Help (metaeditor)

 

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.

 
https://www.mql5.com/en/job
 
underthesun22: I need help
You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 
//-------------------------------------------------------------------------------------------------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

Reason: