hey Im a newbie to but I can see that
if(Period() >= PERIOD_M1 && Period() < PERIOD_M5) is the same as just writing if(Period() == PERIOD_M1 )
what kind of variable is theAtrPeriod and theAtrPeriod2 ? i think global variable may be trying to operate with wrong variable ? cant comment on this until I know.
What accuracy issues are you having with iATR ? It probably isnt iATR but your code. If you attach the whole EA code, it might be easier to see the problem
I think its to do with the GlobalVariableGet but I am new to this so I am unsure.
hey Im a newbie to but I can see that
if(Period() >= PERIOD_M1 && Period() < PERIOD_M5) is the same as just writing if(Period() == PERIOD_M1 )
what kind of variable is theAtrPeriod and theAtrPeriod2 ? i think global variable may be trying to operate with wrong variable ? cant comment on this until I know.
What accuracy issues are you having with iATR ? It probably isnt iATR but your code. If you attach the whole EA code, it might be easier to see the problem
Hi
The different atr periods are for use with different timeframes. I will sort the condition statements for the time periods.
The iATR seems to round value up, so for example, the iATR may show a value of 0.0022 and then the metaquotes will show 0.0021 which is the correct reading. My EA does rely on accurate ATR which is why I would like to use the values of the metaquotes ATR.
Unless there is a different way to does this?
Antony
Hi
The different atr periods are for use with different timeframes. I will sort the condition statements for the time periods.
The iATR seems to round value up, so for example, the iATR may show a value of 0.0022 and then the metaquotes will show 0.0021 which is the correct reading. My EA does rely on accurate ATR which is why I would like to use the values of the metaquotes ATR.
Unless there is a different way to does this?
Antony
You can set the time frames like this
double iATR1 = iATR (symbol(), PERIOD_M1, int period, 0 )
double iATR2 = iATR (symbol(), PERIOD_M1, int period,1)
double iATR3 = iATR (symbol(), PERIOD_M5, int period,0)
double iATR4 = iATR (symbol(), PERIOD_M5, int period, 1 )
and as I have done, name the variables differently. Its a bit easier to work with I think.
why are you using GlobalVariableSet ?
and I think the digits variable may perform differently in different settings, I would just use the number 5 there.
"The iATR seems to round value up,"
It does not round up behind the scenes, so if you assume the value and use it elsewhere, and you dont pass it through other variables unneccesarily it should work. it is difficult to see what you are doing without seeing all the code. I have a few ATR EA's you could look through for ideas if you pm me your email address I will send them
Hi
The site wont let me post the EA as it is too long, but the Atr posted above is how it is calulated then used in condition statements in the EA.
If I divide the iATR by 1.0000000046511560159 it will output the correct value, so that number is the diffence.
Thanks
Antony
"why are you using GlobalVariableSet ?"
I am new to coding so I have done thsi by looking at example, the actual code means nothing to me :(
Thanks
Antony
You can set the time frames like this
double iATR1 = iATR (symbol(), PERIOD_M1, int period, 0 )
double iATR2 = iATR (symbol(), PERIOD_M1, int period,1)
double iATR3 = iATR (symbol(), PERIOD_M5, int period,0)
double iATR4 = iATR (symbol(), PERIOD_M5, int period, 1 )
Besides that, iATR calls built-in indicator, while your modified indicator must be called with iCustom,
Will I have to use iCustom to call the metaquotes atr indicator that will be attached to the same chart?
Thanks
Antony
The iAtr does work but I want the EA to call on the metaquotes indicator that is attached to the same chart as the EA, so what is the problem with the current global variables setup that I have?
Thanks
Antony
- 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 have an EA that uses ATR, but because of issues in accuracy I am having with the iATR I have decided to use the metaquotes indicator for the EA to reference, but iATR as backup incase the indicator is not attached to the same chart.
The metaquotes indicator is returning a value of 0.0000 for the EA, can anyone see what is wrong here please?
Here is the code for the EA, but I am a newbie at coding:
Here is the modified metaquotes indicator:
Thanks
Antony