To get me started on the road to recovery I would like to ask for basic coding help.
I want to simply make an exercise indicator that simply plots a horizontal line at the maximum rate achieved during the last 2 years, and the minimum rate for the last 2 years.
And for every new tick that comes in, it should simply check if the new tick is > than the current maximum or not. If it is, the line should simply move to the new maximum.
Same for the minimum. If the new rate is < the current minimum, the horizontal line should be moved to the new minimum.
To give an idea of where/when I'm from.
In the old days, pointers were the only way to manage arrays of indeterminate size. Each element had an memory adress to it, that linked to the next element in memory.
These days it seems arrays can simply be declared and the pointers are sorted out automatically?
Would I be correct if I say, that the simplest way to do this, would be to load the rates in Month timeframe, and somply declare an array with 24 elements.
Then using a for loop I can evaluate the min and max of each of the 24 elements with a temporary one. After 24 iterations, my temporary variables will contain the min and max values.
Then it's a case of plotting a horizontal line at both those variable values.
Is this still how this would be tackled in MQ5?
Would anyone mind just writing me the code. I think after I get a simple thing like this done, I can get the feel for the changes from my old days code, to the new modern day MQ5.
Thanks in advance!
Declare some variables :
Initialize it as needed :
fromDate=TimeCurrent()-2*365*24*3600; // Approximately 2 years, can be modified for more accuracy
Create your 2 horizontal lines (code not provided).
And in OnCalculate() :
int limit=(prev_calculated==0) ? 0 : prev_calculated-1;
Exactly what I needed!
Not directly related to your question, but also remember to use F1 key when you need to quickly find information about some part of the code. Just highlight the part of the code in MetaEditor and hit F1. This was really helpful when I was learning the ropes regarding MQL5.