Download MetaTrader 5

deference between start() and tick()

To add comments, please log in or register
alirezaDavid
22
alirezaDavid  
Hi
what is deference between start() function and tick function in mql4?
qjol
3243
qjol  

OnStart

The OnStart() function is the Start event handler, which is automatically generated only for running scripts. It must be of void type, with no parameters:

void OnStart();

For the OnStart() function, the int return type can be specified.


Start

The Start event is a special event for script activation after it is loaded. This event is processed by OnStart handler. The Start event is not send to Expert Advisors or custom indicators.

OnTick

The NewTick event is generated for Expert Advisors only when a new tick for a symbol is received, to the chart of which the Expert Advisor is attached. It's useless to define the OnTick() function in a custom indicator or script, because the NewTick event is not generated for them.

The Tick event is generated only for Expert Advisors, but this does not mean that Expert Advisors required the OnTick() function, since not only NewTick events are generated for Expert Advisors, but also events of Timer, BookEvent and ChartEvent are generated. It must be declared as the void type, with no parameters:

void OnTick();


NewTick

The NewTick event is generated if there are new quotes, it is processed by OnTick() of Expert Advisors attached. In case when OnTick function for the previous quote is being processed when a new quote is received, the new quote will be ignored by an Expert Advisor, because the corresponding event will not enqueued.

All new quotes that are received while the program is running are ignored until the OnTick() is completed. After that the function will run only after a new quote is received. The NewTick event is generated irrespective of whether automated trade is allowed or not ("Allow/prohibit Auto trading" button). The prohibition of automated trading denotes only that sending of trade requests from an Expert Advisor is not allowed, while the Expert Advisor keeps working.

The prohibition of automated trading by pressing the appropriate button will not stop the current execution of the OnTick() function. OnTick() is not started when the window of Expert Advisor properties is open.


https://docs.mql4.com/runtime/event_fire#start

alirezaDavid
22
alirezaDavid  
tanks for help :)
whroeder1
15573
whroeder1  
alirezaDavid: what is deference between start() function and tick function in mql4?
See Event Handling Functions - MQL4 Documentation
New Function
EA
Indicator
 Script
 OnStart

Start
 OnInitInit
Init
Init
 OnDeinitDeinit
DeinitDeinit
 OnTickStart


 OnTimernew
new
n/a
 OnTesternew
n/a
n/a
 OnChartEventnew
new
n/a
 OnCalculate
Start

To add comments, please log in or register