Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 and start trading today!
Weixing Meng
201
Weixing Meng 2016.02.04 06: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.
Zirkon
123
Zirkon 2016.02.04 07:23  
a2495432675:
No, it can't.
honest_knave
969
honest_knave 2016.02.04 07: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(). 

Weixing Meng
201
Weixing Meng 2016.02.04 09:13  
zirkoner:
No, it can't.
Thank you.
Weixing Meng
201
Weixing Meng 2016.02.04 09: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! 

honest_knave
969
honest_knave 2016.02.04 09: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

Weixing Meng
201
Weixing Meng 2016.02.04 10: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 

honest_knave
969
honest_knave 2016.02.04 10: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. 

Weixing Meng
201
Weixing Meng 2016.02.05 03: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!

ahmad waliyudin
5
ahmad waliyudin 2016.02.05 13: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  

/
To add comments, please log in or register