//+——————————————————————+
//| Gulzaar Robot Test A.mq4 |
//| Gulzaar |
//| http://gulzaarfx.blogspot.com |
//+——————————————————————+
#property copyright “Gulzaar”
#property link “http://gulzaarfx.blogspot.com”
//—- input parameters
extern double LotSize=0.1, MACDone=8, MACDtwo=21, MACDSignal=5;
extern int StopLoss=50;
extern int EMAdistance=15;
//+——————————————————————+
//| expert start function |
//+——————————————————————+
int start()
{ //START BRACKET
//—Variable declaration
double MACDCurrent, SignalCurrent, rsiValue, TwentyOneEMA, FiftyFiveEMA, FiveEMA, EightSMA, BigDaddy; //200 EMA:)
int ticket, cnt, total;
//—-Checking for enough Bars——//
if(Bars<100)
{
Print(“bars less than 100″);
return(0);
}
//—-Assigning Values to trade criteria——–//
MACDCurrent=iCustom(NULL,0,”MACD_12_26_9″,MACDone,MACDtwo,MACDSignal,2,0);
SignalCurrent=iCustom(NULL,0,”MACD_12_26_9”,MACDone,MACDtwo,MACDSignal,3,0);
rsiValue=iRSI(NULL,0,14,PRICE_CLOSE,0);
TwentyOneEMA=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,0);
FiftyFiveEMA=iMA(NULL,0,55,0,MODE_EMA,PRICE_CLOSE,0);
FiveEMA=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,0);
EightSMA=iMA(NULL,0,8,0,MODE_SMA,PRICE_CLOSE,0);
BigDaddy=iMA(NULL,0,200,0,MODE_EMA,PRICE_CLOSE,0);
StopLoss=StopLoss*Point;
double Distance=EMAdistance*Point;
//——-Done——//
total = OrdersTotal();
if(total<1) //Start main program body if no orders are open /// IF A
{ //IF A BRACKET OPEN
if(AccountFreeMargin()<(1000*LotSize)) //IF B
{ //IF B BRACKET OPEN
Print(“We have no money. Free Margin = “, AccountFreeMargin());
return(0); //IF B
} //IF B BRACKET CLOSE
//Checking for LONGS
if(MACDCurrent>SignalCurrent && rsiValue<72 && TwentyOneEMA>FiftyFiveEMA && TwentyOneEMA>BigDaddy+Distance && FiveEMA>EightSMA)//IF C
{ //IF C BRACKET OPEN
ticket=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,StopLoss,0,NULL,78652,0,NULL); //EXECUTE LONG
if(ticket>0)//IF D
{ //IF D BRACKET OPEN
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print(“BUY order opened : “,OrderOpenPrice());
} //IF D BRACKET CLOSE
else Print(“Error opening BUY order : “,GetLastError());
return(0); //IF C
} //IF C BRACKET CLOSE
//Checking for SHORTS
if(MACDCurrent<SignalCurrent && rsiValue>28 && TwentyOneEMA<FiftyFiveEMA && TwentyOneEMA<BigDaddy-Distance && FiveEMA<EightSMA)//IF E
{ //IF E BRACKET OPEN
ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,StopLoss,0,NULL,78652,0,NULL); //EXECUTE LONG
if(ticket>0)//IF F
{ //IF F BRACKET OPEN
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print(“SELL order opened : “,OrderOpenPrice());
} //IF F BRACKET CLOSE
else Print(“Error opening SELL order : “,GetLastError());
return(0);
} //IF E BRACKET CLOSE
return(0); //IF A
} //IF A BRACKET CLOSE
//GETTING IN THE MARKET SCRIPTS are DONE———————————————//
//GETTING OUT OF THE MARKET——————//
for(cnt=0;cnt<total;cnt++) //Seeing whether there is an open position or not
{ //FOR BRACKET
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position // IF Z
OrderSymbol()==Symbol()) // check for symbol
{ //IF Z BRACKET
if(OrderType()==OP_BUY) // long position is opened // IF Y
{ // IF Y BRACKET
// should it be closed?
if(MACDCurrent<SignalCurrent && FiveEMA<EightSMA) //IF X
{ //IF X BRACKET
OrderClose(OrderTicket(),OrderLots(),Bid,3,NULL); // close position
return(0); // exit
} //IF X BRACKET CLOSE
} //IF Y BRACKET CLOSE
else // go to short position
{ //ELSE BRACKET
// should it be closed?
if(MACDCurrent>SignalCurrent && FiveEMA>EightSMA) //IF W
{ //IF W BRACKET
OrderClose(OrderTicket(),OrderLots(),Ask,3,NULL); // close position
return(0); // exit
} //IF W BRACKET CLOSE
} //ELSE BRACKET Close
} //IF Z BRACKET Close
} //FOR BRACKET Close
return(0);
} //START BRACKET CLOSE
//+——————————————————————+
//BE PROFITABLE!!!!——-//