Meta Trader 4 - fully automatic bot - FOREX

Job ID: 40062105

Budget: $15 – $25 USD

//+------------------------------------------------------------------+
//| Simple Moving Average EA |
//+------------------------------------------------------------------+
#property strict

input double LotSize = 0.01;
input int FastMA = 9;
input int SlowMA = 21;
input int StopLoss = 200;
input int TakeProfit = 400;

double fastMA_prev, fastMA_now;
double slowMA_prev, slowMA_now;

void OnTick()
{
fastMA_now = iMA(NULL, 0, FastMA, 0, MODE_EMA, PRICE_CLOSE, 0);
fastMA_prev = iMA(NULL, 0, FastMA, 0, MODE_EMA, PRICE_CLOSE, 1);

slowMA_now = iMA(NULL, 0, SlowMA, 0, MODE_EMA, PRICE_CLOSE, 0);
slowMA_prev = iMA(NULL, 0, SlowMA, 0, MODE_EMA, PRICE_CLOSE, 1);

// BUY signal
if (fastMA_prev < slowMA_prev && fastMA_now > slowMA_now)
{
if (OrdersTotal() == 0)
{
OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3,
Ask - StopLoss * Point,
Ask + TakeProfit * Point,
"Buy Order", 0, 0, clrBlue);
}
}

// SELL signal
if (fastMA_prev > slowMA_prev && fastMA_now < slowMA_now)
{
if (OrdersTotal() == 0)
{
OrderSend(Symbol(), OP_SELL, LotSize, Bid, 3,
Bid + StopLoss * Point,
Bid - TakeProfit * Point,
"Sell Order", 0, 0, clrRed);
}
}
}