Saturday, July 14, 2018

Simple SMA Robot

Simple SMA robot use only standerd account this EA not work propper on micro/nano account.

//CODE START

extern int MagicNumber=10001;
extern double Lots =0.02;
extern double TakeProfit=5;
//-------------------------------------------
void OnTick()
{
//we create a string variable for signal
string signal="";
//we calculate the moving average  20 candles for the signal
double MyMovingAverage = iMA(_Symbol,_Period,20,0,MODE_SMA,PRICE_CLOSE,0);
//if the moving average is below the candle price
if (MyMovingAverage<Close[0])
{
//set the signal variable to buy
signal="buy";
}
//if the moving average above the current price
if (MyMovingAverage>Close[0])
{
//set the signal variable to sell
signal="sell";
}
//buy 10 microlot
if (MyMovingAverage<Close[0]&& OrdersTotal()==0)
OrderSend(_Symbol,OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*_Point,"SMA ROBOT",MagicNumber,0,Green);
//sell 10 microlot
if (MyMovingAverage>Close[0] && OrdersTotal()==0)
OrderSend (_Symbol,OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*_Point,"SMA RONBOT",MagicNumber,0,Red);
//chart output for the signal
Comment ("The current signal is :",signal);
}


//CODE END

No comments:

Post a Comment