Can return be replaced by continue ?

Back to topics list To post a new topic, please log in or register
avatar
16
a2495432675 2016.02.04 07:23
 
void OnTick()
  {
//--- check for history and trading
   if(Bars<100 || IsTradeAllowed()==false)
      return;     // Can this return be replaced by continue ? After this return, it back to the start of Ontick function ? 
//--- calculate open orders by current symbol
   if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
   else                                    CheckForClose();
//---
  } 
//The blue part is my question, thank you very much.
avatar
125
zirkoner 2016.02.04 08:23 #
 
a2495432675:
No, it can't.
avatar
736
honest_knave 2016.02.04 08:41 #
 

As soon as the next tick comes in, it will return to the beginning of OnInit() anyway.

If you wish to process something between ticks, you're best to use OnTimer(). 

avatar
16
a2495432675 2016.02.04 10:13 #
 
zirkoner:
No, it can't.
Thank you.
avatar
16
a2495432675 2016.02.04 10:16 #
 
honest_knave:

As soon as the next tick comes in, it will return to the beginning of OnInit() anyway.

If you wish to process something between ticks, you're best to use OnTimer(). 

Thank you.

Still have question. I'm a beginner. 

Ontick() and OnInit() are same thing ? 

OnTimer()? OnTicks() ? OnInit ? zzzzzzzz…

I'll check in MetaEditor…but maybe I can not fully understand those things haha.

Thank you a lot! 

avatar
736
honest_knave 2016.02.04 10:20 #
 

This should hopefully help explain https://docs.mql4.com/basis/function/events

But the basics:

OnInit runs once when the EA/indicator starts.

OnTick (EAs) and OnCalculate (indicators) run whenever a new tick comes in 

OnTimer runs on a time delay

OnDeinit runs once when the EA/indicator stops

avatar
16
a2495432675 2016.02.04 11:17 #
 
honest_knave:

This should hopefully help explain https://docs.mql4.com/basis/function/events

But the basics:

OnInit runs once when the EA/indicator starts.

OnTick (EAs) and OnCalculate (indicators) run whenever a new tick comes in  

// What if when sometimes, the ticks just keep coming in and non-stop ? Everytime, when there is a new tick, EA go back to the start of Ontick() ? Thank you a lot !

// Or the EA go through from the beginning to the end, and then check another new tick?  Thanks again!

OnTimer runs on a time delay

OnDeinit runs once when the EA/indicator stops 

avatar
736
honest_knave 2016.02.04 11:38 #
 

OnTick will run whenever a new tick comes in.

New tick... OnTick runs

Another new tick... OnTick runs

Another new tick... OnTick runs 

If your EA hasn't finished processing OnTick before the next tick comes in, it will queue OnTick to run again immediately after it finishes.

But it will only queue 1 tick. So if 5 ticks come through before OnTick finishes, it will run OnTick once more (not 5 times more).

 

The other events OnInit or OnDeinit are designed to run once... at the start and at the end. This also happens if you change chart timeframes. Don't put code here that you want to run every tick. 

 

avatar
16
a2495432675 2016.02.05 04:43 #
 
honest_knave:

OnTick will run whenever a new tick comes in.

New tick... OnTick runs

Another new tick... OnTick runs

Another new tick... OnTick runs 

If your EA hasn't finished processing OnTick before the next tick comes in, it will queue OnTick to run again immediately after it finishes.

But it will only queue 1 tick. So if 5 ticks come through before OnTick finishes, it will run OnTick once more (not 5 times more). // If there is 5 ticks like you said, so it run according the lastest tick after OnTick finishes right ?

 

The other events OnInit or OnDeinit are designed to run once... at the start and at the end. This also happens if you change chart timeframes. Don't put code here that you want to run every tick. 

 Thank you very much for all you info. Really helpful to me. Thank you!

avatar
1
waliyudiinfx 2016.02.05 14:35 #
 

maaf master tolong saya buatkan code sebagai filter supaya ea saya setelah  terkena  TP jangan open lagi   contoh open posisi  SELL ketika RSI> 70 .. TP =10 ;  jika RSI masih di area 70 jangan open lagi ketika sudah TP tetapi menunggu sinyal berikutnya

 

terima kasih  

Back to topics list  

To add comments, please log in or register