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.
Can please someone help me o make this work?
void OnTick()
{
// 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 array1 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);
if ( // Check if the 20 candle EA is above the 50 candle EA
( myMovingAverageArray1[0]>myMovingAverageArray2[0])
&& ( myMovingAverageArray2[1]>myMovingAverageArray1[1])
)
trade. "Buy(0.10, NULL,Ask,Ask -300* _Point,Ask+150*_Point, NULL ;"