The 20's [ea]

Author: Copyright � 2005, TraderSeven
Profit factor:
1.58
Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself
3 Views
0 Downloads
0 Favorites
The 20's [ea]
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------------------+
//|                            ------------                       The 20's v0.20 |
//+------------------------------------------------------------------------------+
#property copyright "Copyright © 2005, TraderSeven"
#property link      "TraderSeven@gmx.net"
 
//            \\|//             +-+-+-+-+-+-+-+-+-+-+-+             \\|// 
//           ( o o )            |T|r|a|d|e|r|S|e|v|e|n|            ( o o )
//    ~~~~oOOo~(_)~oOOo~~~~     +-+-+-+-+-+-+-+-+-+-+-+     ~~~~oOOo~(_)~oOOo~~~~
// This EA has 2 main parts.
// Variation=0
// If previous bar opens in the lower 20% of its range and closes in the upper 20% of its range then sell on previous high+10pips.
// If previous bar opens in the upper 20% of its range and closes in the lower 20% of its range then buy on previous low-10pips.
// 
// Variation=1
// The previous bar is an inside bar that has a smaller range than the 3 bars before it.
// If todays bar opens in the lower 20% of yesterdays range then buy.
// If todays bar opens in the upper 20% of yesterdays range then sell.
//
//01010100 01110010 01100001 01100100 01100101 01110010 01010011 01100101 01110110 01100101 01101110 



//----------------------- USER INPUT
extern int TakeProfit=10;
extern int TrailingStop=20;//starts after TakeProfit is reached, 0=off
extern int Variation=1;	 

//----------------------- MAIN PROGRAM LOOP
double YesterdaysRange;
double Top20;
double Bottom20;
int Lots=1;
int slip=0;
double Stoploss=200;
double OrderDay=99;
int start()

{
// ---------------- START OF DAY???
 int h = TimeHour(CurTime());
 int m = TimeMinute(CurTime());
 int s = TimeSeconds(CurTime());

 
if(h==0 && m==0 && OrdersTotal()==0)
  {

YesterdaysRange=(High[1]-Low[1]);
Top20=High[1]-(YesterdaysRange*0.20);
Bottom20=Low[1]+(YesterdaysRange*0.20);

if(Variation==0)//original system
  {
  if(Open[1]>=Top20 && Close[1]<=Bottom20 && Ask<(Low[1]-0.010) && Day()!=OrderDay)
    { 
    OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Low[1]-(10*Point),Ask+(2*TakeProfit*Point),0,0,Blue);
    OrderDay=Day();
    }
  
  if(Close[1]>Top20 && Open[1]<Bottom20 && Bid>(High[1]+0.010) && Day()!=OrderDay)
    { 
    OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,High[1]+(10*Point),Bid-(2*TakeProfit*Point),0,0,Red);
    OrderDay=Day();
    }  
  }
   
 if(Variation==1)//with narrow range and inside bar
   { 
   if((High[4]-Low[4])>YesterdaysRange && (High[3]-Low[3])>YesterdaysRange && (High[2]-Low[2])>YesterdaysRange && High[1]<High[2] && Low[1]>Low[2])
     {
     if(Open[0]<=Bottom20 && Day()!=OrderDay)
       { 
       OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Low[1]-(100*Point),Ask+(2*TakeProfit*Point),0,0,Blue);
       OrderDay=Day();
       }
  
     if(Open[0]>=Top20 && Day()!=OrderDay)
       { 
       OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,High[1]+(100*Point),Bid-(2*TakeProfit*Point),0,0,Red);
       OrderDay=Day();
       } 
     
     }
   }
   
}   


if((Bid-OrderOpenPrice()>=TakeProfit*Point && OrderType()==OP_BUY) || (OrderOpenPrice()-Ask>=TakeProfit*Point && OrderType()==OP_BUY))
{


// ---------------- TRAILING STOP
if(TrailingStop>0)
{ 
     OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
     if((OrderType() == OP_BUY || OrderType() == OP_BUYSTOP) && 
(OrderSymbol()==Symbol()))
         {
            if(TrailingStop>0) 
              {                
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid- 
Point*TrailingStop,OrderTakeProfit(),0,Aqua);
                     return(0);
                    }
                 }
              }
          }
     if((OrderType() == OP_SELL || OrderType() == OP_SELLSTOP) && 
(OrderSymbol()==Symbol()))
         {
            if(TrailingStop>0)  
              {                
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if(OrderStopLoss()==0.0 || 
                     OrderStopLoss()>(Ask+Point*TrailingStop))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice
(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Aqua);
                     return(0);
                    }
                 }
              }
          }
}   
} 
 
// ---------------- END OF DAY???
h = TimeHour(CurTime());
m = TimeMinute(CurTime());
s = TimeSeconds(CurTime());

 
 Comment(h,":",m,":",s);
 
 if(h==23 && m==59 && s>0 && OrdersTotal()>0)
   {
   OrderDay=9999;
   OrderSelect(0, SELECT_BY_POS);
   if(OrderType()==OP_BUY)
     {
     OrderClose(OrderTicket(),1,Bid,10*Point);
     }   
     
   if(OrderType()==OP_SELL)
     {
     OrderClose(OrderTicket(),1,Ask,10*Point);     
     }
   }



 if(h==23 && m==59 && s>0 && OrdersTotal()>0)
   {
   OrderDay=9999;
   OrderSelect(0, SELECT_BY_POS);
   if(OrderType()==OP_BUY)
     {
     OrderClose(OrderTicket(),1,Bid,10*Point);
     }   
     
   if(OrderType()==OP_SELL)
     {
     OrderClose(OrderTicket(),1,Ask,10*Point);     
     }
   }

}

Profitability Reports

EUR/USD Jan 2025 - Jul 2025
1.51
Total Trades 10
Won Trades 9
Lost trades 1
Win Rate 90.00 %
Expected payoff 6.10
Gross Profit 180.00
Gross Loss -119.00
Total Net Profit 61.00
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.09
Total Trades 9
Won Trades 4
Lost trades 5
Win Rate 44.44 %
Expected payoff -90.44
Gross Profit 80.00
Gross Loss -894.00
Total Net Profit -814.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.18
Total Trades 8
Won Trades 7
Lost trades 1
Win Rate 87.50 %
Expected payoff 1.93
Gross Profit 100.27
Gross Loss -84.82
Total Net Profit 15.45
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.42
Total Trades 7
Won Trades 5
Lost trades 2
Win Rate 71.43 %
Expected payoff -19.86
Gross Profit 100.00
Gross Loss -239.00
Total Net Profit -139.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
5.00
Total Trades 6
Won Trades 5
Lost trades 1
Win Rate 83.33 %
Expected payoff 13.33
Gross Profit 100.00
Gross Loss -20.00
Total Net Profit 80.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.25
Total Trades 8
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 3.50
Gross Profit 140.00
Gross Loss -112.00
Total Net Profit 28.00
-100%
-50%
0%
50%
100%

Comments