STOP & REVERSE Orders

MQL4 Experten Integration

Auftrag beendet

Ausführungszeit 17 Stunden

Spezifikation

Hi, I am trying to insert STOP & REVERSE Orders into the void UpdateBE() of my EA with the following trial and error self-coding, but seems not right...


I am not sure how to use the proper return function, is it just return or return(0) ? and also where to place the return function correctly.


1. I want my EA to close the current open order and open the new reversed order (buy to sell or sell to buy) at certain price level from the opening price.


2. I want my EA to keep doing it but maximum 3 times (if the STOP & REVERSE has been triggered for 3 times- adjustable to 5 times), 

but just one pending stop & reverse order per 1 time.


I am not a coder so I need a coder to help me with this. Thanks in advance.


Regards,

Joe




void UpdateBE()

{

if(UpdateToBE1 <= 0)

return;


for(int i = OrdersTotal() - 1; i >= 0; i--)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

  {

  if(!IsThisChartOrder())

  continue;

 

  if(OrderType() == OP_BUY && OrderOpenPrice() > OrderStopLoss() && Bid - OrderOpenPrice() >= (UpdateToBE1 * Poin))

  {

  OrderModifySafe(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + (BE_LockPLPip1 * Poin), OrderTakeProfit(), 0);

  }

  else if(OrderType() == OP_SELL && OrderOpenPrice() < OrderStopLoss() && OrderOpenPrice() - Ask >= (UpdateToBE1 * Poin))

  {

  OrderModifySafe(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - (BE_LockPLPip1 * Poin), OrderTakeProfit(), 0);

  }

 

  if(OrderType() == OP_BUY && OrderOpenPrice() > OrderStopLoss() && Bid - OrderOpenPrice() >= (UpdateToBE2 * Poin))

  {

  OrderModifySafe(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + (BE_LockPLPip2 * Poin), OrderTakeProfit(), 0);

  }

  else if(OrderType() == OP_SELL && OrderOpenPrice() < OrderStopLoss() && OrderOpenPrice() - Ask >= (UpdateToBE2 * Poin))

  {

  OrderModifySafe(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - (BE_LockPLPip2 * Poin), OrderTakeProfit(), 0);

  }

 

  if(StopReverse_ON)

  {

  //if(OrdersTotal() > 3)

  //   return;

 

  double lots = CalculateLotSize();

  lastOrderTime = TimeCurrent();

 

  if(OrderType() == OP_BUY && OrderOpenPrice() > OrderStopLoss() && Bid < OrderOpenPrice()

  && NormalizeDouble(Bid - OrderStopLoss(), Digits) <= NormalizeDouble((StopReverse_PreparePip * Poin), Digits))

  {

                        OrderClose(OrderTicket(), OrderLots(), OrderStopLoss() + (StopReverse_PreparePip * Poin), Slippage);

  return;

  //OrderSendSafe(Symbol(), OP_SELL, lots, OrderStopLoss(), Slippage, OrderStopLoss() + (StopLoss * Poin), OrderStopLoss() - (TakeProfit1 * Poin), "Reversed 1 BUY ", EAMagicNo, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Red);

  OrderSendSafe(Symbol(), OP_SELLSTOP, lots, OrderStopLoss() + (StopReverse_PreparePip * Poin), Slippage, OrderStopLoss() + (StopLoss * Poin), OrderStopLoss() - ((TakeProfit1+10) * Poin), "Reversed 2 BUY ", EAMagicNo, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Red);

  return;

  }

  else if(OrderType() == OP_SELL && OrderOpenPrice() < OrderStopLoss() && Ask > OrderOpenPrice()

  && NormalizeDouble(OrderStopLoss() - Ask, Digits) <= NormalizeDouble((StopReverse_PreparePip * Poin), Digits))

  {

                        OrderClose(OrderTicket(), OrderLots(), OrderStopLoss() - (StopReverse_PreparePip * Poin), Slippage);

  return;

  //OrderSendSafe(Symbol(), OP_BUY, lots, OrderStopLoss(), Slippage, OrderStopLoss() - (StopLoss * Poin), OrderStopLoss() + (TakeProfit1 * Poin), "Reversed 1 SELL ", EAMagicNo, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Green);

  OrderSendSafe(Symbol(), OP_BUYSTOP, lots, OrderStopLoss() - (StopReverse_PreparePip * Poin), Slippage, OrderStopLoss() - (StopLoss * Poin), OrderStopLoss() + ((TakeProfit1+10) * Poin), "Reversed 2 SELL ", EAMagicNo, TimeCurrent() + D'1970.01.01 1' * OrderExpirationHours, Green);

  return;

  }

  return; //return(0);

  }

  }

}

}

Bewerbungen

1
Entwickler 1
Bewertung
(88)
Projekte
143
39%
Schlichtung
21
19% / 48%
Frist nicht eingehalten
30
21%
Frei

Projektdetails

Budget
20- USD
Ausführungsfristen
bis 3 Tag(e)