Download MetaTrader 5
To add comments, please log in or register
Subscribe to signals right in MetaTrader. It is easy!
underthesun22
15
underthesun22 2014.09.27 09:54 

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.

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.09.27 10:28  
https://www.mql5.com/en/job
whroeder1
13596
whroeder1 2014.09.27 13:27  
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.
Donald Gibson
482
Donald Gibson 2014.09.27 17:21  
//-------------------------------------------------------------------------------------------------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

/
To add comments, please log in or register