escape2display test2

Profit factor:
0.35
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
escape2display test2
//+------------------------------------------------------------------+
//|                                                      escape.mq4 |
//|                                    Copyright © 2008, OGUZ BAYRAM |
//|                                            es_cape77@hotmail.com |
//+------------------------------------------------------------------+

extern double lTakeProfit = 40;
extern double sTakeProfit = 40;
extern double lTrailingStop = 40;
extern double sTrailingStop = 40;

extern int Slippage = 3;

extern double Lots = 0.01;
extern int fma =12;
extern int sma =21;
extern int numbot = 1;  // number of open trades
extern int StopL = 50; // stop loss
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "Sappie Scalp";
extern bool UseSound = true;
extern bool FractionalPips = true;
extern bool Show_Settings = true;
extern string NameFileSound = "Alert.wav";


int init()
{

//----------------------- SHOW EA SETTING ON THE CHART
//----------------------- SOURCE : CODERSGURU
   if(Show_Settings==true) subPrintDetails();
   else Comment("");

}

void deinit() {
   Comment("");
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start(){

//----------------------- SHOW EA SETTING ON THE CHART
//----------------------- SOURCE : CODERSGURU
  // if bars less than 100 dont trade
   if(Bars<100){
      Print("bars less than 100");
      return(0);
   }
   // number of digits after decimal
   if (Digits==3 || Digits==5)
   
   // end if  long take profit less than 10
   if(lTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
    // end if  short take profit less than 10
   if(sTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
// assigns values of close price to di close (ie created shorthand for close price
   double diClose0=iClose(NULL,5,0);
   // assigns values of sma price to dima1 (ie created shorthand 
   double diMA1=iMA(NULL,5,sma,0,MODE_EMA,PRICE_CLOSE,0);
   // assigns values of close price to di close (ie created shorthand for close price
   double diClose2=iClose(NULL,5,0);
   // assigns values of fma price to dima3 (ie created shorthand 
   double diMA3=iMA(NULL,5,fma,0,MODE_EMA,PRICE_CLOSE,0);

   if(AccountFreeMargin()<(1000*Lots)){
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);
   }
   //if not (! means not) exitpositions then buy/sell
   if (!ExistPositions()){
      //if closing price > SMA then buy
      if ((diClose0>diMA3)&& (diMA1>diMA3)){
         OpenBuy();
         return(0);
      }
      
      
      if ((diClose0<diMA1) && (diMA1<diMA3)){ 
         OpenSell();
         return(0);
      }
      
      // if close price < fma then sell
      
   }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   return (0);
}

/// egit if more than open trades = true
bool ExistPositions() {
for (int i=numbot; i<OrdersTotal(); i++) {   /// changed i++ to i = 10
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol()) {
return(True);
}
} 
}  
return(false);
}
void TrailingPositionsBuy(int trailingStop) { 

   RefreshRates();
   for (int i=numbot; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol()) { 
            if (OrderType()==OP_BUY) { 
               if (NormalizeDouble(Bid,4)-OrderOpenPrice()>trailingStop*Point) { 
                  if (OrderStopLoss()<NormalizeDouble(Bid,4)-trailingStop*Point) 
                     ModifyStopLoss(NormalizeDouble(Bid,4)-trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void TrailingPositionsSell(int trailingStop)
 { 
 RefreshRates();
   for (int i=numbot; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol()) { 
            if (OrderType()==OP_SELL) { 
               if (OrderOpenPrice()-NormalizeDouble(Ask, 4)>trailingStop*Point) { 
                  if (OrderStopLoss()>NormalizeDouble(Ask, 4)+trailingStop*Point ) 

                     ModifyStopLoss(NormalizeDouble(Ask, 4)+trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void ModifyStopLoss(double ldStopLoss) { 
   bool fm;
   ldStopLoss = ((NormalizeDouble(Bid,4))+StopL*Point);  /// line added
   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 = ((NormalizeDouble(Bid,4))+StopL*Point); // was 0
   
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_BUY,ldLot,NormalizeDouble(Ask, 4),Slippage,ldStop,ldTake,lsComm,0,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 

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

void subPrintDetails() 
{
   string sComment   = "";
   string sp         = "----------------------------------------\n";
   string NL         = "\n";

   sComment = sp;
   sComment = sComment + "lTakeProfit=" + DoubleToStr(lTakeProfit,0)  + NL;
   sComment = sComment + "sTakeProfit=" + DoubleToStr(sTakeProfit,0)  + NL;
   sComment = sComment + "lTrailingStop=" + DoubleToStr(lTrailingStop,0)  + NL;
   sComment = sComment + "sTrailingStop=" + DoubleToStr(sTrailingStop,0)  + NL;
  
   sComment = sComment + sp;
   sComment = sComment + "FractionalPips=" + FractionalPips + NL;
  

   sComment = sComment + "Lots=" + DoubleToStr(Lots,2) +  NL;
   
   sComment = sComment + sp;
  
   Comment(sComment);
}

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
0.47
Total Trades 2325
Won Trades 857
Lost trades 1468
Win Rate 36.86 %
Expected payoff -0.12
Gross Profit 241.48
Gross Loss -512.86
Total Net Profit -271.38
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.17
Total Trades 2677
Won Trades 475
Lost trades 2202
Win Rate 17.74 %
Expected payoff -0.34
Gross Profit 187.75
Gross Loss -1087.11
Total Net Profit -899.36
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.50
Total Trades 3003
Won Trades 1161
Lost trades 1842
Win Rate 38.66 %
Expected payoff -0.15
Gross Profit 456.99
Gross Loss -917.83
Total Net Profit -460.84
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.27
Total Trades 2173
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -0.27
Gross Profit 218.19
Gross Loss -798.17
Total Net Profit -579.98
-100%
-50%
0%
50%
100%

Comments