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

 
Janis Ozols #:

Or is there some easier way to get this value?

   zz=iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,0,InpBackstep);
   if(zz!=EMPTY_VALUE)
     {prev_zz=curr_zz; curr_zz=zz;}
 
Janis Ozols #:

Attention question: is it a valid approach to loop through the values of the indicator buffer, starting with a zero shift deep down, calling the iCustom function at each iteration, until the resulting value is different from EMPTY_VALUE?

yes

Janis Ozols #:

Or is there some simpler way to get this value?

no

 

How should I write the code so that it would perform the following actions?


tick-check for open sell order within +/- (up/down) range of 10 pips from the price, if no open sell order

If i'm not sure i've got an open Sell order, then i should open a Sell order. The book is similar to C++.

I'm sorry if these questions are too wise.


 
valentin104 #:

How to write the code so that it would perform the following.


tick-check for open sell order within +/- (up/down) range of 10 pips from the price, if no open sell order

If i'm not sure i've got an open Sell order, then i should open a Sell order. The book is similar to C++.

I'm sorry if these questions are too clever.

Go through opened deals and compare the opening price - whether it falls within the Ask+10 to Ask-10 range, if it does, it means you have an open deal.

"As a last resort, open a Codebase and see how to do it)

 

valentin104 #:

Tick-check for an open sell order within +/- (up/down) of the price 10 pips, if not, open a sell order

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(FindOrders(OP_BUY)<1) покупаем;
   if(FindOrders(OP_SELL)<1) продаем;
  }
//+----------------------------------------------------------------------------+
int FindOrders(int ot=-1)
  {
   int order=0;
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(ot==OP_BUY&&OrderType()==ot)
           {
            if(OrderOpenPrice()>Bid-10*Point&&OrderOpenPrice()<Bid+10*Point)
            order=1;
           }
         if(ot==OP_SELL&&OrderType()==ot)
           {
            if(OrderOpenPrice()>Ask-10*Point&&OrderOpenPrice()<Ask+10*Point)
            order=1;
           }
        }
     }
   return(order);
  }
//+----------------------------------------------------------------------------+
 
MakarFX #:
thank you
 
valentin104 #:
thank you


 
MakarFX #:


I see. I'm just a scared Belorussian.
 
valentin104 #:
I see. I'm just a scaredy-goosey Belorussian.
Sorry, I wasn't thinking)
 

Mihail Matkovskij #:

Thank you. It didn't have any effect for some reason.

Reason: