Indicators: View the Value in OnCalculate Parameters

 

View the Value in OnCalculate Parameters:

This is a utility for beginning indicator programmers, or others, that want to have a look at values provided by OnCalculate and a few other functions. The indicator shows: 1) The most recent value provided with the most recent OnCalculate call. 2) The previous value from the previous OnCalculate call. 3) The first value from the first time onCalculate executed.

View the Value in OnCalculate Parameters

Author: LukeB

 

There is also a mq4 version of this at: https://www.mql5.com/en/forum/158115.

Using OnCalculate
Using OnCalculate
  • 2016.01.25
  • www.mql5.com
Please find attached an indicator that does nothing but display the values passed to OnCalculate - and a few other values from functions common in...
 

I'm new to MQL5 and programming in general. I started with a couple beginner video courses and somehow I found this indicator which I was just using to wrap my head around stuff like prev_calculated, etc. Today I decided to look over the code to see if I could understand how it worked, because it seemed shockingly complex for such a seemingly simple thing. But, now I'm starting to understand what's going on, and I must say it's genius how you combined updating underlying data readings on every tick, but then bottlenecking the text and text string update rate via a global variable that flags to update the actual chart objects that display the text on the next OnTimer, which is controlled in frequency by the EventSetTimer().

What I've noticed so far is that dealing with lots of chart objects tends to use a lot more CPU than dealing with plotting buffers, so I find this technique to be amazing and I will be using it in my own indicators. I suppose this technique is commonly used but it's the first time I've seen it.

I must say, for such a simple indicator you really went out of your way to make it immaculate as if it was a much more complex project. Or is it normal for people to go that hard for such simple stuff? :D

 

I know this is a long time after (necro-posting?) but thank you for this very helpful and nicely done code.


Regards, Amundo