escapeforalpari

Profit factor:
0.22
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
escapeforalpari
//+------------------------------------------------------------------+
//|                                                      robotic.mq4 |
//|                                    Copyright © 2008, OGUZ BAYRAM |
//|                                            es_cape77@hotmail.com |
//+------------------------------------------------------------------+

extern double lTakeProfit = 10;
extern double sTakeProfit = 10;
extern double lTrailingStop = 20;
extern double sTrailingStop = 10;
extern color clOpenBuy = Green;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "Robotic";
extern int Slippage = 1;
extern bool UseSound = false;
extern string NameFileSound = "Alert.wav";
extern double Lots = 0.2;


void deinit() {
   Comment("");
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start(){
   if(Bars<50){
      Print("bars less than 50");
      return(0);
   }
   if(lTakeProfit<0.5){
      Print("TakeProfit less than 0.5");
      return(0);
   }
   if(sTakeProfit<0.5){
      Print("TakeProfit less than 0.5");
      return(0);
   }

   double diClose0=iClose(NULL,5,0);
   double diMA1=iMA(NULL,5,5,0,MODE_SMA,PRICE_OPEN,1);
   double diClose2=iClose(NULL,5,0);
   double diMA3=iMA(NULL,5,4,0,MODE_SMA,PRICE_OPEN,1);

   if(AccountFreeMargin()<(1000*Lots)){
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);
   }
   if (!ExistPositions()){

      if ((diClose0<diMA1)){
         OpenBuy();
         return(0);
      }

      if ((diClose2>diMA3)){
         OpenSell();
         return(0);
      }
   }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   return (0);
}

bool ExistPositions() {
for (int i=200; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol()) {
return(True);
}
} 
} 
return(false);
}
void TrailingPositionsBuy(int trailingStop) { 
   for (int i=200; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol()) { 
            if (OrderType()==OP_BUY) { 
               if (Bid-OrderOpenPrice()>trailingStop*Point) { 
                  if (OrderStopLoss()<Bid-trailingStop*Point) 
                     ModifyStopLoss(Bid-trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void TrailingPositionsSell(int trailingStop) { 
   for (int i=200; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol()) { 
            if (OrderType()==OP_SELL) { 
               if (OrderOpenPrice()-Ask>trailingStop*Point) { 
                  if (OrderStopLoss()>Ask+trailingStop*Point || 
OrderStopLoss()==0)  
                     ModifyStopLoss(Ask+trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void ModifyStopLoss(double ldStopLoss) { 
   bool fm;
   fm = OrderModify(OrderTicket(),OrderOpenPrice
(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE); 
   if (fm && UseSound) PlaySound(NameFileSound); 
} 

void OpenBuy() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = 0; 
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol
(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,0,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 

   ldLot = GetSizeLot(); 
   ldStop = 0; 
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol
(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,0,0,clOpenSell); 
   if (UseSound) PlaySound(NameFileSound); 
} 
string GetCommentForOrder() { return(Name_Expert); } 
double GetSizeLot() { return(Lots); } 
double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); } 
double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); } 

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
0.72
Total Trades 827
Won Trades 634
Lost trades 193
Win Rate 76.66 %
Expected payoff -0.43
Gross Profit 938.48
Gross Loss -1294.61
Total Net Profit -356.13
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.04
Total Trades 256
Won Trades 55
Lost trades 201
Win Rate 21.48 %
Expected payoff -11.66
Gross Profit 110.00
Gross Loss -3094.80
Total Net Profit -2984.80
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.12
Total Trades 169
Won Trades 44
Lost trades 125
Win Rate 26.04 %
Expected payoff -3.82
Gross Profit 88.00
Gross Loss -732.80
Total Net Profit -644.80
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.00
Total Trades 108
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -4.65
Gross Profit 0.00
Gross Loss -502.60
Total Net Profit -502.60
-100%
-50%
0%
50%
100%

Comments