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

 
MakarFX:

void()

And in my code, which I posted here, where should this void() be inserted ?
Thank you

 
ANDREY:

And in my code that I posted here, where should this void() be inserted ?
Thanks

do not insert - create

delete from OnTick()

and then

//--- input parameters
input int      Points=30;
double LoU;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60); // таймер в секундах
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   LoU=Bid;
   if(Low[0]<LoU) {LoU=Low[0];}
   SendOrder(); 
  }
//+------------------------------------------------------------------+
void SendOrder()
  {
   if ((Bid-Points*Point)>=LoU)
     {
      if(OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,0,0,"300",0)) LoU=Low[0];
     }
  }
 
MakarFX:

do not insert - create

remove from OnTick()

and then...

I'm intrigued by this..... And what exactly does this void() do with respect to my code and with respect to my purpose ?

I understood that calculations from OnTick() are passed into other functions. And wherever it occurs void(), what function does it perform?
Thank you

 
ANDREY:

I'm intrigued by this..... And what exactly does this void() do in relation to my code and in relation to my target ?
Thanks

Works on a timer.

 
MakarFX:

Working on a timer

Does the timer tell the program how often to check the code, on every tick, or on every minute or hourly or daily candlestick?
If so, should I set the timer to check on every minute candle and it will take much less time to execute the code during testing?

 
ANDREY:

Does the timer tell the program how often to check the code, on every tick, or on every minute or hour or day candle?

I signed it.

EventSetTimer(60); // таймер в секундах
 
MakarFX:

I signed it.

Why not in minutes?

Or is it actually in minutes? Or will the code be executed at every second, not every tick. There are more ticks than seconds and sometimes much more...
 
ANDREY:

Why not in minutes?

Andrei, decide what you want. either every tick or in seconds. set it to 86400 seconds...and it will be once a day

 
MakarFX:

do not insert - create

remove from OnTick()

and then

Here is your code

input int      Points=30;
double LoU,Pr;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60); // таймер в секундах
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   LoU=Bid;
   if(Low[0]<LoU) {LoU=Low[0];}
   SendOrder(); 
  }
//+------------------------------------------------------------------+
void SendOrder()
  {
   if ((Bid-Points*Point)>=LoU)
     {
      if(OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,0,0,"300",0)) LoU=Low[0];
     }
  }

But it didn't open any order for some reason.

 
MakarFX:

Andrei, decide what you want, either every tick, or in seconds. Set it to 86400 seconds...and it's once a day

Got it now. That's what I wanted to hear, that you can set it to any interval.
Thank you.

Reason: