EA Très simple

BT ;

//+——————————————————————+

///+——————————————————————+
//|                                              SCRIPTOR AOCCI.mq4 |
//|                                                                  |
//+——————————————————————+
extern double Takeprofit    =  47;
extern bool open_buy  = 1;
extern bool open_sell = 1;
//—-
double ao ;  double ao1;   double cci;  double cci1;
//—-
int buy = 0; int sell =0;
//+——————————————————————+
//|                                                                  |
//+——————————————————————+
int start()
{
ao  =iAO( NULL,0,0);      //   ao_15_0 =
ao1 =iAO( NULL,0,1);      //    ao_15_0 =
//—-
cci =iCCI(NULL,0,55,PRICE_CLOSE, 0);
cci1=iCCI(NULL,0,55,PRICE_CLOSE, 1 );
//—-
buy = 0; sell =0;
for(int i=0; i < OrdersTotal(); i++)    {
if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES ) ==1) {
if( OrderSymbol()==Symbol() ) {//&& OrderMagicNumber() == Magic )
if( OrderType()==OP_BUY )  buy++;
if( OrderType()==OP_SELL ) sell++;
} }  }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
if( ao1 < 0  ) { //  fermeture buy si profit > takeprofit
for( i=0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol()==Symbol())  {
if (OrderType()==OP_BUY )  {
if( OrderProfit() > Takeprofit ) {// Profit_En_Euro )
OrderClose(OrderTicket(), OrderLots(), Bid, 3 );
} } } } }
//—————————————————-
if( ao1 > 0 ) {  //  fermeture Sell si profit > takeprofit
for( i=0; i < OrdersTotal(); i++)  {
OrderSelect(i, SELECT_BY_POS);
if( OrderSymbol()==Symbol())  {
if( OrderType()==OP_SELL )  {
if( OrderProfit() > Takeprofit) { //Profit_En_Euro )
OrderClose(OrderTicket(),OrderLots(), Ask, 3);
} } } } }

Comment( « \n », « \n », « \n »,
« \n », »                              BUY   « , buy,
« \n », »                              SELL  « , sell );

if( open_buy  && buy < 30 ) {
if( cci1 < -100 &&  cci >= -100 ) {
OrderSend( Symbol(), OP_BUY, 0.1, Ask, 3,0,0,NULL, 0, 0,PaleGreen);
return(0);
}  }

if( open_sell && sell < 30 )  {
if(  cci1 > 100 &&  cci <=100 )  {
OrderSend(Symbol(), OP_SELL, 0.1, Bid, 3, 0,0, NULL, 0, 0, Yellow);
return(0);
} }
//—-
return(0);
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Publicités