Your Help Please: Using global variable to allow 1 indicator to plot different lines each time 'next' copy applied to chart.

To add comments, please log in or register
ukt
473
ukt  
Hello all you code dudes!

My aim is to learn how to use one .ex4 many times on main chart by using concept of 'instances'
Each time indicator (ind) is applied to chart a differently colored moving average line is plotted,
showing that instance(n) has run...

(brief pseudo code)

init() if global var not exist create,set global var to 1 set color of ind line for this ind instance if global var does exist get global var value increment global var if global var value at max allowed ind instances then exit else set global var to next available ind instance value set color of ind line for this ind instance exit start() if first time entered then log 'instance(n) entered' message for each bar on chart plot line: with moving average value assigned to this instance exit deinit() if last instance on chart delete global var if instance value greater than max allowed exit log exit message for this instance number exit


My problem is...

Below is log [timestamps removed] of what happens is run more than one instance.
The first plots it's line and stays running.
The second/third/.../fifth runs - log message that running then exit.
IE, start() is not entered! deinit() called instead of start()

Can you enlighten me as to why start() not entered on instances >1 ???
^^^^^^^^^^^^^^^^^^^^
MOST appreciated! hope to hear from you ;)


===================
.mq4 SOURCE FILE ATTACHED.
===================

globalVariableTest GBPUSD,Daily: removed
globalVariableTest GBPUSD,Daily: deinitialized
globalVariableTest GBPUSD,Daily: Exit:instance(3) deinit() deinit() called instead of start()
globalVariableTest GBPUSD,Daily: initialized
globalVariableTest GBPUSD,Daily: instance(3) running on:GBPUSD, session minutes:1440
globalVariableTest GBPUSD,Daily: loaded successfully
globalVariableTest GBPUSD,Daily: removed
globalVariableTest GBPUSD,Daily: deinitialized
globalVariableTest GBPUSD,Daily: Exit:instance(2) deinit() deinit() called instead of start()
globalVariableTest GBPUSD,Daily: initialized
globalVariableTest GBPUSD,Daily: instance(2) running on:GBPUSD, session minutes:1440
globalVariableTest GBPUSD,Daily: loaded successfully
globalVariableTest GBPUSD,Daily: instance(1) start() entered AND blue line plots
globalVariableTest GBPUSD,Daily: initialized
globalVariableTest GBPUSD,Daily: instance(1) running on:GBPUSD, session minutes:1440
globalVariableTest GBPUSD,Daily: loaded successfully
Files:
To add comments, please log in or register