scalping





//+------------------------------------------------------------------+
//|                                                     scalping.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.scalping.nm.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.scalping.nm.ru"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
extern int SL=57,TP=100,TS=35; 
extern double UDayChanel=0.004;
extern int StartTime=6,EndTime=11;
extern double lots=1;
int init()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int total,cnt;
double HighPrice,LowPrice,DayChanel;
//----
HighPrice=iHigh(Symbol(),PERIOD_D1,0);
LowPrice=iLow(Symbol(),PERIOD_D1,0);
DayChanel=HighPrice-LowPrice;

total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   if(OrderType()<=OP_SELL && 
   OrderSymbol()==Symbol())   
   {
      if(OrderType()==OP_BUY)   
      {
         if(Hour()>EndTime)
         {
            OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
            return(0); 
         }
         if(TS>0)  
         {                
            if(Bid-OrderOpenPrice()>Point*TS)
            {
               if(OrderStopLoss()<Bid-Point*TS)
               {
                  OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TS,OrderTakeProfit(),0,Red);
                  return(0);
               }
            }
         }
      }
      else 
      {
         if(Hour()>EndTime)
         {
            OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
            return(0); 
         }
         if(TS>0)  
         {    
            if((OrderOpenPrice()-Ask)>(Point*TS))
            {
               if(OrderStopLoss()==0.0 || 
               OrderStopLoss()>(Ask+Point*TS))
               {
                  OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TS,OrderTakeProfit(),0,Red);
                  return(0);
               }
            }
          }
      }
   }
}
 
if (Hour()>=StartTime &&   Hour()<EndTime)
{
   if (AccountFreeMargin()>=2000) lots=1;
   if (AccountFreeMargin()>=3000) lots=1;
   if (AccountFreeMargin()>=4000) lots=2;
   if (AccountFreeMargin()>=5000) lots=3;
   if (AccountFreeMargin()>=6000) lots=4;
   if (AccountFreeMargin()>=7000) lots=5;
   if (AccountFreeMargin()>=8000) lots=6;
   if (AccountFreeMargin()>=9000) lots=7;
   if (AccountFreeMargin()>=10000) lots=8;
   if (AccountFreeMargin()>=11000) lots=9;
   if (DayChanel>=UDayChanel)
   {
   Print(Day(),"/",Month()," - ",Hour(),":",Minute()," - H",HighPrice," L",LowPrice," Ch",DayChanel," OB:",MathCeil(AccountFreeMargin()/1000)," LOT",lots);
      total=OrdersTotal();
      if (total==0)
      {
         OrderSend(Symbol(),OP_SELL,lots,LowPrice,0,LowPrice+SL*Point,LowPrice-TP*Point,"Scalp",16384,0,Red); OrderSend(Symbol(),OP_BUY,1,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Blue); 
         OrderSend(Symbol(),OP_BUY,lots,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Red); 
         return(0);
      }
      if (total==1)
      {
         OrderSelect(1,SELECT_BY_POS,MODE_TRADES);
         if (OrderSymbol()==Symbol())
         {
            if (OrderType()==OP_BUYSTOP)
            {
               OrderSend(Symbol(),OP_SELLSTOP,lots,LowPrice,0,LowPrice+SL*Point,LowPrice-TP*Point,"Scalp",16384,0,Red); OrderSend(Symbol(),OP_BUY,1,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Blue); 
            }
            if (OrderType()==OP_SELLSTOP)
            {
               OrderSend(Symbol(),OP_BUYSTOP,lots,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Red); OrderSend(Symbol(),OP_BUY,1,HighPrice,0,HighPrice-SL*Point,HighPrice+TP*Point,"Scalp",16384,0,Blue); 
            }
         }
         return(0);
      }
      if (total==2)
      {
         return(0);
      }
   }
}

//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders

It Closes Orders by itself
It can change open orders parameters, due to possible stepping strategy
It automatically opens orders when conditions are reached

Other Features:

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.25 Total Net Profit:-6408.00

BackTest : EURUSD on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.89 Total Net Profit:-2273.00

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.43 Total Net Profit:-5793.00

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.63 Total Net Profit:-3513.00

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-05-01 to 2010-05-31 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-06-01 to 2010-06-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.25 Total Net Profit:-8559.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.33 Total Net Profit:-9818.38

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.59 Total Net Profit:-5335.55

Request Backtest for scalping


From : (yyyy/mm/dd) To: (yyyy/mm/dd)

Pair: Period: