fly7680:
It is probably extremely rare that MAs will be exactly equal. You may read both as 1.00001, but one could have an actual value of something like 1.000009
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.
ok thanks, but in the code it is not correct the signal level because I have used the ">" operator.
Right?
Right?
I have already offered an explanation. Print the values to see the exact values to more than 5 Digits.
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); }
I'll make a test with this code.
thank you
thank you
Thanks again to everyone for the help, but so does not work. The values of the moving average 50 and 5, if they are equal in the spark plug 1, are still read as true.
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); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
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.