Mistake number one: you create an indicator handle at every tick! This is a gross mistake. The indicator handle must be created once (this is desired in OnInit).
Indicator example: MA Other TimeFrame Correct
- www.mql5.com
I want to make an indicator with a simple moving average.
I want to see the average of the last 30 days (always, regardless of the timeframe that I am looking at at that moment).
I was trying to do something like what I put below. But i don't get a constant value when i change timeframe.
Does anyone know how to do this correctly?
It is obvious that it will never be quite the same! They will always be slightly different.
You are using the principal of equivalence of the moving average period. but obviously at the lower time-frames you have more data and so the moving average will be more "refined" while at the higher time-frame there is less data and the moving average will be more "rough".
That is to be expected! They are equivalent but not the same!
Mistake number one: you create an indicator handle at every tick! This is a gross mistake. The indicator handle must be created once (this is desired in OnInit).
Indicator example: MA Other TimeFrame Correct
Thank you very much for your answers !! Very Much appreciated !!
It is obvious that it will never be quite the same! They will always be slightly different.
You are using the principal of equivalence of the moving average period. but obviously at the lower time-frames you have more data and so the moving average will be more "refined" while at the higher time-frame there is less data and the moving average will be more "rough".
That is to be expected! They are equivalent but not the same!
I think I have too big an error between the different values of the averages in each timeframe ... it is almost + -0.1000 in XAGUSD ...
Is there something wrong in my code? I mean ... can this result be improved in any way?
Thank you very much for your answers !! Very Much appreciated !!
Mistake number one: you create an indicator handle at every tick! This is a gross mistake. The indicator handle must be created once (this is desired in OnInit).
Indicator example: MA Other TimeFrame Correct
Read the SMA of 30 off of the D1. Use iBarShift to get the D1 shift.
Remember to repaint all bars with a D1 shift of zero.
How to do your lookbacks correctly #9 - #14 & #19
Read the SMA of 30 off of the D1. Use iBarShift to get the D1 shift.
Remember to repaint all bars with a D1 shift of zero.
How to do your lookbacks correctly #9 - #14 & #19
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to make an indicator with a simple moving average.
I want to see the average of the last 30 days (always, regardless of the timeframe that I am looking at at that moment).
I was trying to do something like what I put below. But i don't get a constant value when i change timeframe.
Does anyone know how to do this correctly?
Thank you so much!!