Adding Adjustable Stop Loss to EA.

 

Hi all,

I am really new to this EA things and programming.

Is it possible to put adjustable Stop Loss to EA.

Maybe something like this. Put 'True' if we want to use the adjustable Stop Loss. Put 'False' an it will follow the origin rules and logic.

Tq on your response.

 
peatdexter:

Hi all,

I am really new to this EA things and programming.

Is it possible to put adjustable Stop Loss to EA.

Maybe something like this. Put 'True' if we want to use the adjustable Stop Loss. Put 'False' an it will follow the origin rules and logic.

Tq on your response.


yes possible

it is called "trailing stops"

try the below code, may help:

   for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
      int MyOrderSelect=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL && 
         OrderSymbol()==Symbol() && 
         OrderMagicNumber()==MagicNumber
         )
        {
         if(OrderType()==OP_BUY)
           {
            if(TrailingStop>0)
              {
               if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
                    {
                     int MyOrderModify=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
                    }
                 }
              }
           }
         else
           {
            if(TrailingStop>0)
              {
               if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     int MyOrderModify=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
                    }
                 }
              }
           }
        }
     }


in case you want to get a top quality work then open a job in the freelance section.

https://www.mql5.com/en/job/new

 
Mohammad Soubra:

yes possible

it is called "trailing stops"

try the below code, may help:


in case you want to get a top quality work then open a job in the freelance section.

https://www.mql5.com/en/job/new

I'll take a look. Tq then.