When I wrote it in here I've done that (stupid) declaration but I've declared the array in the EA like this:
(between external variables declaration and init function)
double DIF_MA[2];
double WPR[];
I've got the EA working well with this while loop (calling the indicator with iCustom):
// Code to find crosses at bar number index
index=0;
ArrayIndex = 0;
while(ArrayIndex <= 5)
{
DIF_MA[0] = iCustom(NULL,0,"Signal - WPR (Smooth)",Periodo,Periodo_Smooth,2,index);
DIF_MA[1] = iCustom(NULL,0,"Signal - WPR (Smooth)",Periodo,Periodo_Smooth,2,index+1);
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++;
}
And my intention was to "insert" the indicator in the EA.
Because the indicator is only to smooth the WPR indicator with a certain period.
My idea was to create an array called WPR[] with that for cycle and than use it with the iMAOnArray in the while cycle instead of calling the custom indicator.
// 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++;
}
I really don't understand why does it give me an endless loop this way and it does not with iCustom ! :(
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
.
Hi GumRai, thank you so much for your help! :)
When I wrote it in here I've done that (stupid) declaration but I've declared the array in the EA like this:
(between external variables declaration and init function)
I've got the EA working well with this while loop (calling the indicator with iCustom):
And my intention was to "insert" the indicator in the EA.
Because the indicator is only to smooth the WPR indicator with a certain period.
My idea was to create an array called WPR[] with that for cycle and than use it with the iMAOnArray in the while cycle instead of calling the custom indicator.
I really don't understand why does it give me an endless loop this way and it does not with iCustom ! :(
.
.
Thank you for your answer WHRoeder!
I think that I've already understood the problem.
I will see if I can fix it. As I am a newbie now I need to hard think how to solve it.
I will be back! :)
Thank you all for your patience.
.
.
Finally I understood my problem!!!
I was so focused on the while cycle that I has not looking to the for cycle.. ;)
Hours looking for the obviously... ... It's hard to be newbie... LOL..
I need to know WPR_Smooth value in past values and I was doing it as I was only working with the current time..
Now, with a bigger WPR Array and with iMAOnArray counting all that array (zero value) it is finally working.
No need to have a signal indicator anymore! :)
.
Once again.. Thank you so much for your patience to help me! :)
.