.
It's so frustrating.. Because it doesn't give any error..
Looking to the Journal separator it just stays stopped in the inputs line after the "loaded successfully".
This way I cannot know what is wrong.. :(
.
What do you expect and what do you get instead?
.
It really does not work!
It compiles without errors.
But when I run a backtest nothing happens.
I belive that with this part of code it is too slow. I belive something in that code is slowing down (almoast stoped!) the EA.
As I said.. I belive.. Because it doesn't do nothing!
.
The Expert Advisor with the iCustom function calling the indicator with iMAOnArray is working well.
That way, it means that this part of code is the one that is causing the troubles.
Sory but I cannot put the EA in here since the "property copyright" don't allow me.
.
.
Please, can someone help me with this? I'm stuck in this.. :(
Is that commented piece of code good? Or does it have same error?
.
extern int Periodo = 20; extern int Periodo_Smooth = 5; int index=0, CrossAt[5], ArrayIndex = 0; double DIF_MA[2]; WPR[]; // Code to find crosses at bar number index index=0; ArrayIndex = 0; ArrayResize(WPR,Periodo+1); ArraySetAsSeries(WPR,true); for (int g=0; g<=Periodo; g++) { WPR[g] = iWPR(NULL,0,Periodo,g); } while(ArrayIndex <= 5) { DIF_MA[0] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index) +50); DIF_MA[1] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index+1) +50); if( (DIF_MA[0]>0 && DIF_MA[1]<=0) || (DIF_MA[0]<0 && DIF_MA[1]>=0) ) // if cross found { CrossAt[ArrayIndex] = index; ArrayIndex++; } index++; }
Please post code that compiles
double DIF_MA[2]; WPR[];
WPR[] is declared without type.
If the code that you show doesn't compile, then it cannot be the code that you are using.
while(ArrayIndex <= 5) { DIF_MA[0] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index) +50); DIF_MA[1] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index+1) +50); if( (DIF_MA[0]>0 && DIF_MA[1]<=0) || (DIF_MA[0]<0 && DIF_MA[1]>=0) ) // if cross found { CrossAt[ArrayIndex] = index; ArrayIndex++; } index++; }
You only increase ArrayIndex if a cross is found while you increase index every pass. Once index hits the size of WPR[], it no longer has anything to calculate with, so you will either get a critical Array out of range error, or you will be stuck in an endless loop

- 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've got an EA that needs to find the last 5 WPR's crosses of (-50 value).
I've made it in a indicator with success:
Now I need it in an EA but I can not do it directly (without using this indicator with iCustom function)!
I've read a lot of posts about iMAonArray() and tryed a lot of things but my limited skills don't help me.
This is how I think it should work. But it do not work!
Please help me discover how to use iMAOnArray() on this case! :)
.