MA 2 Crossover
-
// create an Array for several prices
double myMovingAverageArray1[],myMovingAverageArray2[];// define the properties of the Moving Average1 int movingAverageDefinition1 = iMA (_Symbol,_Period,20,0,MODE_EMA,PRICE_CLOSE); // define the properties of the Moving Average2 int movingAverageDefinition2 = iMA (_Symbol,_Period,50,0,MODE_EMA,PRICE_CLOSE); // sort the price array1 from the current candle downwards ArraySetAsSeries(myMovingAverageArray1,true); // sort the price array2 from the current candle downwards ArraySetAsSeries(myMovingAverageArray2,true); // Defined MA1, one line,current candle,3 candles, store result CopyBuffer(movingAverageDefinition1,0,0,3,myMovingAverageArray1); // Defined MA2, one line,current candle,3 candles, store result CopyBuffer(movingAverageDefinition2,0,0,3,myMovingAverageArray2); // calculate MA1 for the current candle double myMovingAverageValue1=myMovingAverageArray1[0]; // calculate MA2 for the current candle double myMovingAverageValue2=myMovingAverageArray2[0]; if ( // Check if the 20 candle EA is above the 50 candle EA (myMovingAverageArray1[0]>myMovingAverageArray2[0]) && (myMovingAverageArray1[1]<myMovingAverageArray2[1]) ) { Comment ("BUY"); } if ( // Check if the 50 candle EA is above the 20 candle EA (myMovingAverageArray1[0]<myMovingAverageArray2[0]) && (myMovingAverageArray1[1]>myMovingAverageArray2[1]) ) { Comment ("SELL"); }Why the 2 MA cross not activated Buy or Sell
-
Wow. This is for real programmers. Anyone nearby?

-
@rosliomar Where did you get this code? You know, you dont need to code anything when using fxdreema.
Your if-checks only make comments, not trading actions
-
@roar i copy from fxdreema and put in this message box and it came out like that. i tested, it running good. but on real it not work. why?
-
@roar Thank you. what should i do to make it work on real
-
@rosliomar here is what you are trying to do https://fxdreema.com/shared/sVlEMv8U
-
Please excuse my ignorance but...where are the arrays he was asking for?
-
@l-andorrà I don't know why he does this with arrays, he's just inserting MA values into arrays and comparing the arrays, instead of directly comparing two MAs which can be done in fxdreema. No reason to complicate it with arrays.
-
Ok. Thanks.

-
@roar thank you for reply. I follow your EA, when testing the MA line show on the chart. But in real the line not show. Why?. Tq
-
@rosliomar the fxdreema EAs never attach the indicators, they only work on the background. If you want to see the lines, you will have to manually add them