1) You are copying the whole indicator buffer on every tick.
2) In MQL 5, close is not a series unlike MQL 4. You need to make up your mind in which order you want to loop through the
buffers.
On top of what @lippmaje mentioned,
(1) you need to move these lines to OnInit():
mm1 = iMA(Symbol(),Period(),periodoHiLo,1,metodo,PRICE_HIGH); mm2 = iMA(Symbol(),Period(),periodoHiLo,1,metodo,PRICE_LOW);
Because they just need to be executed once, and they need time to complete their work, before you call CopyBuffer().
(2) Then check that this statement is what you want:
if(prev_calculated==0)
because with this, coupled with "return (rates_total);" at the end, your indicator will only be executed once at the first tick.
Fixing (1) and you'll immediately see things being drawn on chart. Fixing (2) as well, and you'll see updates every bar, and fixing @lippmaje's recommendations (together with proper determination of how many bars to compute for every new tick/bar), you'll see improvements in speed.
First of all, thanks @lippmaje and @Seng Joo Thio, for your answers.
This is my first indicator, so I am having trouble to understand the construction structure. The idea here is to calculate the history bars on load of the chart. and calculate the actual bar in real time. Then, when a new bar is started se the value of one that became old now and continue to calculate the new one.
I understood the First point, and changed the mm1 and mm2 to OnInit(), now the second point couldn't get. I don't know about the close. Is the way to return (rates_total - 2) and calculate for this difference?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi.
I am trying to develop a HiLo indicator but I am having trouble with the information that comes from the iMA formula. If I try to use 1 at the iMA formula, it does not dislocate the result.
Here is the code.
I know that it is only running when I load the indicator, but the ideia is to make this work, so I can do the other part later