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

 
Roman Sharanov:

doesno history data say anything?

Thank you for your reply.

 
Igor Makanu:

You seem to be told by the tester that there is no history data, press F2 and download the history, then reload the terminal

All done, thank you very much, it's working.

 
Hi guys! Need your help again! Can you tell me how to make a sequence of numbers N() from 1 ?
int N() {   int n;                      
       n=N();
       return(n+1);}
//+------------------------------------------------------------------+  
void OpenBS() { ....       
    if( ((OpenB-Ask)/ma+TimeB/60) > N() ) { 
        if( OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,NULL,123,0,1)>0 ) {N()} }}
What to change int to make N() spin from void OpenBS() ?
 
Rustam Bikbulatov:
Hi guys! Need your help again! Can you tell me how to make a sequence of numbers N() from 1 ? What to change int to make N() spin from void OpenBS() ?

Maybe like this

int N()
  {
   static int n=0;                      
   n++;
   return n;
  }
 
Konstantin Nikitin:

How about this

Thank you very much!!! Can you tell me how else to zero out? For example, if there are orders then it is calculated. If there are no orders, it is zeroed.

int N()
  {  static int n;
        {if((fMarketOrdersBuy(OP_BUY)==0)) { 
        n=0;}}
        {if((fMarketOrdersBuy(OP_BUY)>=1)) {                       
        n++;}}
   return n;
  }
Why does this method not work?
 
Rustam Bikbulatov:

Thank you very much!!! Can you tell me how else to zero out? For example, if there are orders then it is calculated. If there are no orders then it is zeroed

int N(const int r=0)
  {
   static int n=0;                      
   n = (r==0 ? n : r==1 ? n+1 : 0); // 0-просто возвращаем n, 1-прибавляем 1, в любом другом случае обнуляем
/*
   n = (r>0 ? n+1 : r<0 ? 0 : n); // 0-просто возвращаем n, больше 0 прибавляем 1, меньше 0 обнуляем
*/
   return n;
  }
 
Konstantin Nikitin:

There is no calculation at all. It's zero. Thank you. (chuckles) I'll look into it.)

 
Rustam Bikbulatov:

There is no calculation at all. It's zero. Thank you. (chuckles) I'll look into it.)

Well, you have to ask for it.

N(1);  // прибавит 1, и вернет новый результат.
N(-1); // обнулит и вернет 0
N();   // вернет тот результат который есть без изменений
 
Konstantin Nikitin:

That's how you ask for it

but how do you do it in the form of ?

        if((fMarketOrdersBuy(OP_BUY)==0)) { 
        ...}
        if((fMarketOrdersBuy(OP_BUY)>=1)) {                       
        ...}
 
Konstantin Nikitin:

That's how you call it.

Just noticed that int works by itself regardless of the call to this function. Is it possible to replace it with void type?