Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 373

 
STARIJ:
you have a summation

Thank you! Ran it through, and fixed it! Now it works.

 
Artyom Trishkin:
The order is selected by ticket, and then, after one kilometre of code, you try to modify it. But it may already be closed at that time.

If the order was closed, then OrdersTotal()==0;; respectively, the OrderModify() would not happen at all.

 
ijonhson:

If the order was closed, then OrdersTotal()==0;, respectively, OrderModify() would not take place at all

First, you check the quantity, then you check a lot of code where the position might have closed (but you're already handling a quantity condition greater than zero), and then you select and modify the closed one.
 

Orders can be closed 0.01 lots at a time if the order is a lot of 0.59 for example. A question arises. Is it possible to combine two orders into one? For example, an order with the lot 0.01 and you want to open another order with 0.02 lot. Can they be combined with 0.03 lots to avoid the piling up of orders, and if so, how?

 
install MT5 netting
 
Taras Slobodyanik:
install MT5 netting

no such thing in MT4?

 

Hello again everyone.


With all due respect to the pristine rectangles.


I don't understand - WHY it happily modifies sell orders, but ignores modification of buy orders even when using incense tambourines and other irrational optimization tools.


if (ticket>0)

{

//set a Stop Loss and Take Profit for a Buy order//

if(OrderSelect (ticket, SELECT_BY_TICKET, MODE_TRADES))

{

double sl,tp;

if (type==OP_BUY)

{

sl=OrderOpenPrice () - (StopLoss*_Point);

sl=NormalizeDouble (sl,_Digits);

tp=OrderOpenPrice () + (TakeProfit*_Point);

tp=NormalizeDouble (tp,_Digits);

}

if (type==OP_SELL)

{

sl=OrderOpenPrice () + (StopLoss*_Point);

sl=NormalizeDouble (sl,_Digits);

tp=OrderOpenPrice () - (TakeProfit*_Point);

tp=NormalizeDouble (tp,_Digits);

}

bool mod = false;

int count=0;

while (!mod)

{

mod=OrderModify (ticket, OrderOpenPrice (), sl, tp, 0, clrYellow);

count++;

if (count>=100)

{

mod=true;

break;

 

Figured it out!!!!!

 

Please help me, I'm just learning, if ZZ from one buffer was called from one buffer and ZZ from two buffers, how should I write it correctly?

// - 2 - ======================== Поиск одного экстремума ЗЗ ============================ 
    double ZZCur = 0;
    while(ZZCur == 0 && i < Bars)
      {
       if(iCustom(Symbol(), 0, "FastZZ", Depth, 0, i)!=0.0) ZZCur =(iCustom(Symbol(), 0, "FastZZ", Depth, 0, i);
       else  if(iCustom(Symbol(), 0, "FastZZ", Depth, 1, i)!=0.0) ZZCur =(iCustom(Symbol(), 0, "FastZZ", Depth, 1, i);
       i++;
      }
// - 2 - ============================ Окончание блока ===================================

// - 3 - ======================== Анализ найденного экстремума ========================== 
    if (ZZCur == 0)
      return(False);           // Если ни один из экстремумов не определен, то это ошибка

I am not writing it correctly, how should it be written? Thank you

 

Didn't capture the piece at the top, it makes more sense that way. Please tell me the mistake.

Reason: