WeeklyBreakout_v1.0

Author: Copyright ?2007, Arui
Price Data Components
Series array that contains open time of each bar
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
454.00 %
Total Trades 589
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 19.51
Gross Profit 14741.90
Gross Loss -3250.00
Total Net Profit 11491.90
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
0.00 %
Total Trades 777
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -7.22
Gross Profit 0.00
Gross Loss -5611.98
Total Net Profit -5611.98
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
25.00 %
Total Trades 772
Won Trades 33
Lost trades 739
Win Rate 0.04 %
Expected payoff -6.26
Gross Profit 1594.80
Gross Loss -6426.40
Total Net Profit -4831.60
-100%
-50%
0%
50%
100%
WeeklyBreakout_v1.0
//+------------------------------------------------------------------+
//|                                               WeeklyBreakout.mq4 |
//|                                            Copyright ?2007, Arui |
//|                                    http://www.ea-performance.com |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, Arui"
#property link      "http://www.ea-performance.com"
// This ea is based on SIBKIS's weekly breakout system


extern int    startTime = 0; // GMT time
extern int    startDay = 2;  // Tuesday
extern int    endTime = 19;  
extern int    endDay = 5;    //  Close all orders at the end of Friday


extern int    stopLoss = 100;
extern double lots = 0.1;
extern int    breakEven = 0;
extern int    magicNumber= 2007411;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
    
    if(DayOfWeek()==startDay && TimeCurrent() > StrToTime(startTime+":00")
      && TimeCurrent()< StrToTime(startTime+":10")
      )
    {
    
     if(currentOrders_By_Type(OP_BUYSTOP)==0)  // Send BuyStop order
     {


   double sellPrice = NormalizeDouble(Bid - 50*Point,Digits);
        double sellStopPrice = NormalizeDouble(sellPrice + stopLoss*Point,Digits);
     
         OrderSend(Symbol(),OP_SELLSTOP,lots,sellPrice,3,sellStopPrice,0,"weekly breakout 1.0",magicNumber,0,Yellow);        
   /*     
        double buyPrice  =  NormalizeDouble(Ask + 50*Point,Digits);
        double buyStopPrice =  NormalizeDouble(buyPrice - stopLoss*Point,Digits);
        
        
        OrderSend(Symbol(),OP_BUYSTOP,lots,buyPrice,3,buyStopPrice,0,"weekly breakout 1.0",magicNumber,0,Green);
        
     */   
        
        
     }
     if(currentOrders_By_Type(OP_SELLSTOP)==0) 
     {
     
        double buyPrice  =  NormalizeDouble(Ask + 50*Point,Digits);
        double buyStopPrice =  NormalizeDouble(buyPrice - stopLoss*Point,Digits);
        
        
        OrderSend(Symbol(),OP_BUYSTOP,lots,buyPrice,3,buyStopPrice,0,"weekly breakout 1.0",magicNumber,0,Green);
     
     
     
    /*   
        double sellPrice = NormalizeDouble(Bid - 50*Point,Digits);
        double sellStopPrice = NormalizeDouble(sellPrice + stopLoss*Point,Digits);
     
         OrderSend(Symbol(),OP_SELLSTOP,lots,sellPrice,3,sellStopPrice,0,"weekly breakout 1.0",magicNumber,0,Yellow);
     */
     }
     
    
    }
    
    
    if(breakEven > 0)  moveToBreakeven();
    
    if(DayOfWeek()==endDay && TimeCurrent()>=StrToTime(endTime+":00")&& TimeCurrent()<=StrToTime(endTime+":10")) 
    {
    
     closeAll();
    
    }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

int currentOrders_By_Type(int type)
  {
   int cur_orders = 0;

   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==magicNumber && OrderType()==type)
        {
          cur_orders++;
        }
     }
    
    return(cur_orders);
}


void closeAll(){


    for(int i=0; i<OrdersTotal();i++)
    {
    
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
     if(OrderSymbol() == Symbol() && OrderMagicNumber() == magicNumber)
     {
        
           
           
           if(OrderType()==OP_BUY)  
           {
            OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
           }
           else if(OrderType()==OP_SELL) 
           { 
            OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
           }
           else
           {
            OrderDelete(OrderTicket());
           }    
           
     }
    
   }//end for

}// end closeAll

void moveToBreakeven()
{
   for (int i=0;i<OrdersTotal();i++)
   { 
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
  
      if ( OrderSymbol()==Symbol() && OrderMagicNumber()==magicNumber) 
      {
         if (OrderType()==OP_BUY) 
         {
		
			 if ( breakEven > 0 && Bid-OrderOpenPrice()> breakEven*Point && OrderOpenPrice()!= OrderStopLoss() )    
			 {
			    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Orange);
			 }
         
         }//end buy   

         if (OrderType()==OP_SELL)
         {
          if ( breakEven > 0 && OrderOpenPrice()-Ask>breakEven*Point && OrderOpenPrice()!= OrderStopLoss())  
          {
              OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Orange);
          } 
            
         }//end sell
      }
   
   
   }//end for     



}// end trailing

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---