Asynchronous oncalculate

 

Good morning

In the doc, it is not specifically said that oncalculate is asynchronous.
It is said that the event is launched at each tick

Am I correct in thinking that the instructions in oncalculate are synchronous and each tick launches a new instance of oncalculate?
Instances of Oncalculate launch without waiting for the previous one(s) to complete?


 
Gerard Willia G J B M Dinh Sy:

Good morning

In the doc, it is not specifically said that oncalculate is asynchronous.
It is said that the event is launched at each tick

Am I correct in thinking that the instructions in oncalculate are synchronous and each tick launches a new instance of oncalculate?
Instances of Oncalculate launch without waiting for the previous one(s) to complete?


I have been researching a similar topic; finding arguments for OrderSend and AsyncOrderSend, that I think is applicable to your question, but the answer is highly debated in threads and posts from several years "back".

The short answer, i think, is yes and no (not funny i know!).

From what i read, your comments are all correct: the function is synchronous, however, the deals, and communications with broker, are asynch. So, these functions are both neither and both.

The question you or we need to ask is if the command or instruction we want to use is synchronous or asynchronous, not if the whole function is or isnt.

 
Revo Trades # :

I have been researching a similar topic; finding arguments for OrderSend and AsyncOrderSend, that I think is applicable to your question, but the answer is highly debated in threads and posts from several years "back".

The short answer, i think, is yes and no (not funny i know!).

From what i read, your comments are all correct: the function is synchronous, however, the deals, and communications with broker, are asynch. So, these functions are both neither and both.

The question you or we need to ask is if the command or instruction we want to use is synchronous or asynchronous, not if the whole function is or isnt.

I think that in fact it is all oncalculate which is the thread whose lines of code are synchronous, knowing that these lines of code can launch functions which can be by nature asynchronous, that is to say that a one more thread will be launched.


 
Gerard Willia G J B M Dinh Sy #:

I think that in fact it is all oncalculate which is the thread whose lines of code are synchronous, knowing that these lines of code can launch functions which can be by nature asynchronous, that is to say that a one more thread will be launched.


i think you simplified everything i read over 3 hours, all in 1 sentence haha.

 
Revo Trades #:

i think you simplified everything i read over 3 hours, all in 1 sentence haha.

Lol
 

Short answer. All Indicators of a symbol runs in a single thread, and each tick in OnCalculate is processed one after another. As well any functions like OnChartEvent, OnBookEvent, etc. They are all executed one after another, not simultaneouly.

https://www.mql5.com/en/docs/runtime/running

Documentation on MQL5: MQL5 programs / Program Running
Documentation on MQL5: MQL5 programs / Program Running
  • www.mql5.com
Program Running - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Gerard Willia G J B M Dinh Sy #:
Lol
You may want to read this thread:


 
Dominik Egert #:
You may want to read this thread:


Thx
Reason: