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

 
MakarFX:
Yes

Thanks for the help. If I'm not mistaken, despite the fact that void OnTick() handles each tick, if we useTimeSeconds() inside it, then void OnTick() will handle not each tick, but only the beginning of each minute candle and thus will save runtime of the whole code.

Tell me, if instead of TimeSeconds(), you write in the condition if(Minute() != x), and at the end x= Minute(), it will have the same effect as TimeSeconds()?

Thank you

 
ANDREY:

Thanks for the help. If I'm not mistaken, despite the fact that void OnTick() handles each tick, if we useTimeSeconds() inside it, then void OnTick() will handle not each tick, but only the beginning of each minute candle and thus will save runtime of the whole code.

Tell me, if instead of TimeSeconds(), you write in the condition if(Minute() != x), and at the end x= Minute(), it will have the same effect as TimeSeconds()?

Thanks

bool FlagNewBar=false,
     FlagBegin=true;

void OnTick()

FlagNewBar=false;
   if(BarTime!=Time[0])
     {
      BarTime=Time[0];
      FlagNewBar=true;
     }


   if(FlagNewBar || FlagBegin)
     {
      FlagBegin=false;
.......

)

It's better, you will have a timer outside of sessions as well. And only on a new candle.

But why do you need it that way since it is easier to place a grid of pending orders at the first extremum? This is essentially the same thing with you. The first condition is identifying the extremum and then, if the trend goes down, the orders will be placed after 30 points.

The flagging is needed to work out immediately after being thrown onto the chart. If not needed, then remove the flagging.

 
Valeriy Yastremskiy:

Better still, you will have the timer running out of sessions. But only on a new candle.

And why would you do that, because it is easier to place a grid of pending orders from the first extremum? This is essentially the same thing with you. The first condition is identifying the extremum and then, if the trend goes down, the orders will be placed after 30 points.

The flagging is needed to work out immediately after being thrown onto the chart. If it is not needed, then remove the flagging.

My order opens 30 pips upwards from the local low, i.e. BID minus MINIMUM >= 30 pips.
Thanks for your participation. I will now start to delve into your tips....

 
Valeriy Yastremskiy:

Better still, you will have the timer running out of sessions. But only on a new candle.

And why would you do that, because it is easier to place a grid of pending orders from the first extremum? This is essentially the same thing with you. The first condition is identifying the extremum and then, if the trend goes down, the orders will be placed after 30 points.

The flagging is needed to work out immediately after being thrown onto the chart. If we do not need it, we will remove the flagging.

There was a local minimum. And I set 10 pending orders at the distance of 30,32,34...pips from the local minimum. And then the local low was updated before the price reached the first pending order, and I have to set all the pending orders once again. The way I see it, setting and resetting the pending orders takes a lot of time. And I'm trying to save it.

 
Valeriy Yastremskiy:

Better still, you will have the timer running out of sessions. But only on a new candle.

And why would you do that, because it is easier to place a grid of pending orders from the first extremum? This is essentially the same thing with you. The first condition is identifying the extremum and then, if the trend goes down, the orders will be placed after 30 points.

The flagging is needed to work out immediately after being thrown onto the chart. If not needed, then remove the flagging.

I would be glad if my timer was flogging. But as it turned out in the MT4 tester, the timer does not work.

 
ANDREY:

Thanks for the help. If I'm not mistaken, despite the fact that void OnTick() handles each tick, if we useTimeSeconds() inside it, then void OnTick() will handle not each tick, but only the beginning of each minute candle and thus will save runtime of the whole code.

Tell me, if instead of TimeSeconds(), you write in the condition if(Minute() != x), and at the end x= Minute(), it will have the same effect as TimeSeconds()?

Thank you

      if(TimeMinute(TimeCurrent())!=x)
         x=TimeMinute(TimeCurrent();
 
Valeriy Yastremskiy:

It's better this way,

Can you tell me why we need a "FlagNewBar"?

Isn't it the same thing?

   if(BarTime!=Time[0])
     {
      ........
      BarTime=Time[0];
     }
 

MakarFX:

if(TimeMinute(TimeCurrent())!=x)
         x=TimeMinute(TimeCurrent();


I still do not understand if using the TimeSeconds() or TimeMinute() functions in this case is fundamental and obligatory? After all, you can get the same result as with these functions using one function - Minute( )

if(Minute()!= x)
{

action
x= Minute();

}

Thank you.

 
ANDREY:

I still do not understand if using the TimeSeconds() or TimeMinute() functions in this case is fundamental and obligatory? After all, you can get the same result as with these functions using one function - Minute( )

if(Minute()!= x)
{

action
x= Minute();

}

Thank you.

It's not a matter of principle. Whatever suits you best
 
MakarFX:

Can you tell me why the "FlagNewBar" is needed?

Isn't it the same thing?

It's a habit from BASIC. It's easier to use it) You can do it without it.) And if the condition is inserted in several places, the record is shorter.

Zy. If the logic is branched and hysteresis, you can't do without flags. And it's convenient to print them)
Reason: