MataNui:
Please edit your post . . . Hi,
I have 2 moving averages on an ocillator and i need to get the values (a sort of MA cross of ocillator rather than price) but seem to have a small problem.
Here is the code:
<SNIP>
The problem i am seeinf is that both the slowma and fastma values are the same but obviously they are not if i look at the indicators on the chart. if i comment out the fastma then the slowma will report the correct values. Is it not possible to run iMAOnArray twice? I have even doubled the code to run each against its own array but no different.
Please use this to post code . . . it makes it easier to read.
Here this seems to work.
void start(){ double AO[]; ArrayResize(AO, Bars); ArraySetAsSeries(AO,true); for(int i=Bars; i>=0; i--){ AO[i]=iAO(Symbol(), 0, i); } double fastma = iMAOnArray(AO,0,1,0,MODE_EMA,0); double slowma = iMAOnArray(AO,0,3,0,MODE_EMA,0); Print("fastma="+fastma+"___slowma="+slowma); }
07:58:08 Helping: loaded successfully
07:58:14 Helping test started
07:58:14 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00042853
07:58:55 Helping EURUSD,M1: loaded successfully
07:58:55 Helping test started
07:58:55 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00035827
07:59:57 Helping EURUSD,M1: removed
07:58:14 Helping test started
07:58:14 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00042853
07:58:55 Helping EURUSD,M1: loaded successfully
07:58:55 Helping test started
07:58:55 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00035827
07:59:57 Helping EURUSD,M1: removed
ubzen:
Thanks. That does seem to have worked. Any idea why in this case Symbol() is needed rather than NULL?
Here this seems to work.
07:58:08 Helping: loaded successfully
07:58:14 Helping test started
07:58:14 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00042853
07:58:55 Helping EURUSD,M1: loaded successfully
07:58:55 Helping test started
07:58:55 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00035827
07:59:57 Helping EURUSD,M1: removed
07:58:14 Helping test started
07:58:14 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00042853
07:58:55 Helping EURUSD,M1: loaded successfully
07:58:55 Helping test started
07:58:55 2012.01.02 06:01 Helping EURUSD,M1: fastma=-0.00042853___slowma=-0.00035827
07:59:57 Helping EURUSD,M1: removed
- Symbol/Null is irrelevant. Yours didn't work because you set all elements of the array to the same value.
Your code His for(int i=Bars; i>=0; i--) { AO[i]=iAO(NULL, 0, 0);
for(int i=Bars; i>=0; i--){ AO[i]=iAO(Symbol(), 0, i);
- Both loops are wrong. AO only has Bars elements, 0 to Bars-1. AO[Bars] does not exist.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I have 2 moving averages on an ocillator and i need to get the values (a sort of MA cross of ocillator rather than price) but seem to have a small problem.
Here is the code:
double AO[];
ArrayResize(AO, Bars);
ArraySetAsSeries(AO,true);
for(int i=Bars; i>=0; i--)
{
AO[i]=iAO(NULL, 0, 0);
}
double fastma = iMAOnArray(AO,0,1,0,MODE_EMA,0);
double slowma = iMAOnArray(AO,0,3,0,MODE_EMA,0);
The problem i am seeinf is that both the slowma and fastma values are the same but obviously they are not if i look at the indicators on the chart. if i comment out the fastma then the slowma will report the correct values. Is it not possible to run iMAOnArray twice? I have even doubled the code to run each against its own array but no different.