Hello, today I tried to make an EA, and I was surprised when I tested it, it is 100% accurate, but only with long positions.
so I will post the code, It would be nice if we could iprove it with both(shord and long orders).
conditions of this EA is simple, it’s easy to understand from code.
extern double Lots = 0.01;
extern double TakeProfit = 150;
extern double StopLoss = 80;
double level1;
double level2;
double level0;
int start()
{
int ticket;
double r1 = iRSI(NULL,0,14,PRICE_CLOSE,1);
double r2 = iRSI(NULL,0,14,PRICE_CLOSE,2);
level1 = (iBands(NULL,0,21,3,0,PRICE_OPEN,MODE_UPPER,0)+ 12*Point);
level2 = (iBands(NULL,0,21,3,0,PRICE_OPEN,MODE_LOWER,0)- 12*Point);
level0 = iBands(NULL,0,21,3,0,PRICE_OPEN,MODE_MAIN,0);
//----buy
if((Ask < level2) && (r2<30 && r1>30))
{
//if(iRSI(NULL,0,14,PRICE_CLOSE,1)>70)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"MA sample",16384,0,Green);//Bid+StopLoss*Point
}
}
//----sell
// if((Ask > level1) && (r2>70 && r1<70))
// {
// // if(iRSI(NULL,0,14,PRICE_CLOSE,1)<30)
// {
// ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"MA sample",16384,0,Red);
//
// }
// }
//----close
{
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
{
if ((type == OP_BUY) && (Ask>level0))
{
OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
}
if ((type == OP_SELL) && (Ask<level0))
{
OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
}
}
//----
return(0);
}
sorry for bad english