I wrote a function so an indicator can send one pseudo-tick to chart if the market is closed, any way to improve it?
When you “tick” the chart, the indicator is reloaded. Your static variable will be reset. (EAs are not reloaded.)
When you “tick” the chart, the indicator is reloaded. Your static variable will be reset. (EAs are not reloaded.)
Yeah, the fake tick doesn't reset the static variable but changing timeframes does.
Appears that the fake tick recalculates the indicators without re-executing OnInit(), but changing timeframes definitely reinitializes the indicator(s). Probably better off having everything reinitialize when changing timeframes anyway. Since it only affects charts when the market is closed, I should just accept that. Thanks for looking!
When you “tick” the chart, the indicator is reloaded. Your static variable will be reset. (EAs are not reloaded.)
Do you happen to know if the indicator list is a reliable source for the order of execution of the indicators?
This way, I could only produce the fake tick with the last indicator on the chart list, and it would only execute once per TF change instead of once per indicator per TF change.
UPDATE: Looks like the last indicator in the list is executed first when changing timeframes ... kind of a PITA for personal reasons.Thank you for the suggestion Dominik.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
This code appears to work great when dropping an indicator on a chart when the market is closed. I've prevented recursive calls with a static variable.
Hoping an expert might be willing to evaluate this code for:
- Internal terminal behavior which makes this inadvisable?
- Some cool idea how I can only execute the pseudo-tick one time if loading a template with 5 indicators each using this function? (not critical but if there's a cool way I'd like to learn).
- Anything in my code which is more complicated than necessary?
Thanks, much appreciated!
Function call from end of OnCalculate()
..... sendTickIfMktClosed(); return(rates_total); }
and the function: