I hope I have posted this in the right place. I am fairly new to mql4 so this has me scratching my head
These are 3 lines of code from a much bigger program; so I show just the 3 lines that are confusing me in a simplified form
If I use these. The indicator does not show anything.
double Val1;
Val1 = iMA(NULL,0,LongEMA,0,MODE_EMA,PRICE_HIGH,i);
cross[i] = Val1;
Why does assigning the value to a variable and then assigning that to the array fail? I need to do some calculation to get the indicator I want which is why I need Val1
Cheers
TYIA
Trevor
The buffer only has one value at one bar. You have to use an array to have value for each bar.
Thanks for answering.
Is cross[] not an array?
cross[] is defined in the global section and I thought these 2 lines
SetIndexBuffer(0,cross);
SetIndexStyle(0,DRAW_LINE,STYLE_DASH,1);
set the array
Is that wrong?
It can be displayed either way without any problems as long as there are no mistakes in the program.
It doesn't. Always post all relevant code (using SRC).
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem
We can't see your broken code.
- 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 hope I have posted this in the right place. I am fairly new to mql4 so this has me scratching my head
These are 3 lines of code from a much bigger program; so I show just the 3 lines that are confusing me in a simplified form
If I use these. The indicator does not show anything.
double Val1;
Val1 = iMA(NULL,0,LongEMA,0,MODE_EMA,PRICE_HIGH,i);
cross[i] = Val1;
However, if I use cross[i] = iMA(NULL,0,LongEMA,0,MODE_EMA,PRICE_HIGH,i); everything shows fineWhy does assigning the value to a variable and then assigning that to the array fail? I need to do some calculation to get the indicator I want which is why I need Val1
Cheers
TYIA
Trevor