Cross Moving Avarege: Problem!
Hello everyone, I have a little problem with the moving average cross. The arrow must come out only when the Cross took place, however the code reads even the equal of moving averages.
Right?
I added this code but I can not print the price with tenths more, I might have a little help, please?
myPoint = Point(); if(Digits() == 6 || Digits() == 5 || Digits() == 3) { myPoint *= 10; } return(INIT_SUCCEEDED); }
Uncompiled / untested:
double Lento2 =iMA(NULL, PERIOD_CURRENT, PeriodoLento, 0, MODE_SMA, PRICE_CLOSE, 2+i), Lento1 =iMA(NULL, PERIOD_CURRENT, PeriodoLento, 0, MODE_SMA, PRICE_CLOSE, 1+i), Veloce2=iMA(NULL, PERIOD_CURRENT, PeriodoVeloce, 0, MODE_SMA, PRICE_CLOSE, 2+i), Veloce1=iMA(NULL, PERIOD_CURRENT, PeriodoVeloce, 0, MODE_SMA, PRICE_CLOSE, 1+i); //Indicator Buffer 1 if(Lento2 < Veloce2 && Lento1 > Veloce1) { Buffer1[1+i] = High[1+i] + 1 * myPoint; printf("Lento2: %.8f Lento1: %.8f Veloce2: %.8f Veloce1: %.8f",Lento2,Lento1,Veloce2,Veloce1); } //Indicator Buffer 2 if(Lento2 > Veloce2 && Lento1 < Veloce1) { Buffer2[1+i] = Low[1+i] - 1 * myPoint; printf("Lento2: %.8f Lento1: %.8f Veloce2: %.8f Veloce1: %.8f",Lento2,Lento1,Veloce2,Veloce1); }
thank you
Other ideas?
I also added another condition that should the code to work for as I understand it, but unfortunately all the Sell conditions disappear.
double Lento2 =iMA(NULL, PERIOD_CURRENT, PeriodoLento, 0, MODE_SMA, PRICE_CLOSE, 2+i), Lento1 =iMA(NULL, PERIOD_CURRENT, PeriodoLento, 0, MODE_SMA, PRICE_CLOSE, 1+i), Veloce2=iMA(NULL, PERIOD_CURRENT, PeriodoVeloce,0, MODE_SMA, PRICE_CLOSE, 2+i), Veloce1=iMA(NULL, PERIOD_CURRENT, PeriodoVeloce,0, MODE_SMA, PRICE_CLOSE, 1+i); //Indicator Buffer 1 if(Lento2 < Veloce2 && Lento1 > Veloce1 && MathAbs (Lento1 - Veloce1) > 0.1 // condition to eliminate the equal value ) { Buffer1[1+i] = High[1+i] + DistanzaIcone * myPoint; printf("Lento2: %.8f Lento1: %.8f Veloce2: %.8f Veloce1: %.8f",Lento2,Lento1,Veloce2,Veloce1); }

Hello everyone, I have a little problem with the moving average cross. The arrow must come out only when the Cross took place, however the code reads even the equal of moving averages.