Is it possible to read changes in pre-built indicator (for example: its value changes) through an expert-advisor, and of course - automate the trades based on those reads?
What is the function that is responsible for doing this?
I have tried to look this up on Google, but it appears I can only do things like track object creation or deletion ... called Chart Events.... maybe I'm missing something?
Ok I found it.
In order to use a custom indicator as a tool for a buy / trade decision inside an expert advisor, the function is
iCustom()
Yes, it is possible.
MetaTrader4 Terminal is a software platform, that allows you to launch
1x
soloist Expert Advisor - as an event-driven code-execution algorith per each MT4.GraphNx
concurrent Custom Indicator-s event-driven restricted code-base per each MT4.Graph1x
soloist Script asynchronous code-execution unit per each MT4.GraphThis inventory is important, as you have no other means how to automate complex Trading Algorithmisation but this.
Technical Indicators are executed under one common thread, which poses limitations for real-time robustness plus some restrictions apply for the permitted / forbidden operations that might be coded / compiled / executed in Indicator ( all aim at avoiding any and all possible blocking situations ( ref. solo-thread for all ... ) )
This said, you might have noticed, that both
Expert Advisor
andTechnical Indicator
-s are externally synchronised ( forget for the moment about non-parallel, shared thread execution with principal nanosecond scale of asynchronicity due to resource / code-execution scheduling ) and bound to externally issuedanFxMarketEVENT
in a form of an arriving signal ( once a price moves,MT4.Server
sendsQUOTE
downstream message to theMT4.Terminal
, a.k.a. a Tick ), which once ( if ) received, triggersMQL4
code-execution facilities onlocalhost
:OnTick(){ ...}
# in case of Expert Advisor
OnCalculate(){...}
# in case of Custom Technical Indicator
What is the function that is responsible for this?
Directly? None.
Indirectly? The one you construct and make responsible for registering / monitoring the changes of such value ( be it internally in
MQL4
domain or externally via distributed processing model, incl.GPU
-cluster one for more demanding processing, where internal shared-thread execution fails to meet the timing constraints ):Can do principle
One may create a similarly trivial or a bit more complex PID-monitor and ask from
Expert Advisor
each time anOnTick()
is being called ( thus align the code execution with the internal event-handler at no additional cost ).