The function iMA will create a Moving Average for the specified symbol (and of course you can select the kind of MA, period, etc.).
The funtion iATR will create a period Average True Range indicator.
Create two of them and then subtract to get the distance!
yona22, thank you for the reply, but I think I may not have made myself clear... I want a 2 period EMA of the ATR (18 period) line, not of the price of the symbol.
Any thoughts on this. I am sure it is very simple, but I am just not sure how to code it. I thought perhaps I should use iMAOnArray on an array that contains the ATR values. Would this work?
Please forgive me if I already posted this question. I thought I posted it last night, but now I can find no trace of it.
In a chart window I have an 18 period Average True Range line. Then I drug a moving average into that indicators window and set the parameters for the MA as follows:
period = 2; shift 0; Exponential; and Previous Indicator's Data.
I want to use an increasing gap between these two lines in my EA, but I cannot figure out how to code the EMA2 of the ATR18 into my EA. Can anyone help with this?
Thanks!
fxstr58, I am facing a similar problem with my custom indicator. I am a beginner in metatrader. Did you finally get it? Did you try using iATR() inside iMA()?
Let me know if you have already find a solution. I need it too.
Thanks a lot!
fxstr58, I am facing a similar problem with my custom indicator. I am a beginner in metatrader. Did you finally get it? Did you try using iATR() inside iMA()?
Let me know if you have already find a solution. I need it too.
Thanks a lot!
If I understand this correctly, you want to get ATR values then put an MA on that. In this case, you need to do this:
1. Declare an array of doubles of the size you want for ATR -- number of bars desired.
2. Declare an array of doubles of the size you want for results -- number of bars desired.
3. Use iATR() to fill this array -- do this for as many bars as you declared in step 1 & 2.
4. Use iMAOnArray() on the ATR array you filled up with the period set to 2 and put the results in the second array you declared -- this needs to be a loop.
Please note that you will have what may seem like weird values when the ATR switches from below to above and vice versa.
Hope this helps,
Jon
If I understand this correctly, you want to get ATR values then put an MA on that. In this case, you need to do this:
1. Declare an array of doubles of the size you want for ATR -- number of bars desired.
2. Declare an array of doubles of the size you want for results -- number of bars desired.
3. Use iATR() to fill this array -- do this for as many bars as you declared in step 1 & 2.
4. Use iMAOnArray() on the ATR array you filled up with the period set to 2 and put the results in the second array you declared -- this needs to be a loop.
Please note that you will have what may seem like weird values when the ATR switches from below to above and vice versa.
Hope this helps,
Jon
Thanks Jon, it seems it would work.
Its alot simpler to code and has better performance if you have an indicator to do these calculations
Download SFX_MA_On_ATR and various other useful indis from here
Good Luck
-BB-
thanx BB, but I have to make some changes in that too. Actually, I need a ratio of current ATR to the average ATR for a specified period. As, these are ex4 files (rather than mql) I can't edit it. Thankx anyways.
Dhillon
I have an 18 period Average True Range line. . . . . . .I cannot figure out how to code the EMA2 of the ATR18 into my EA. Can anyone help with this?
If I understand your request, I suggest that you use the EMA formula for calculating the 2 period EMA.
The formula is: EMA (current) = (ATR (current) - EMA (previous)) x multiplier + EMA (previous)
multiplier = 2/(time periods + 1) = 2/(2+1) = 2/3 = 0.667
Let me know if you need more help.
raft
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please forgive me if I already posted this question. I thought I posted it last night, but now I can find no trace of it.
In a chart window I have an 18 period Average True Range line. Then I drug a moving average into that indicators window and set the parameters for the MA as follows:
period = 2; shift 0; Exponential; and Previous Indicator's Data.
I want to use an increasing gap between these two lines in my EA, but I cannot figure out how to code the EMA2 of the ATR18 into my EA. Can anyone help with this?
Thanks!