NatusekoProtrader4HStrategy





//+------------------------------------------------------------------+
//|                                  NatusekoProtrader4HStrategy.mq4 |
//|                                                     FORTRADER.RU |
//|                                              http://FORTRADER.RU |
//+------------------------------------------------------------------+
#property copyright "FORTRADER.RU"
#property link      "http://FORTRADER.RU"
extern string x="Íàñòðîéêè öåíîâûõ EMA:";
extern  int perema1=13;
extern  int perema2=21;
extern  int persma3=55;

extern string x1="Íàñòðîéêè MACD:";
extern int lowema4=5;
extern int fastema4=200;

extern string x2="Íàñòðîéêè MACD Bolinger:";
extern int bbper=20;
extern int bbotcl=1;

extern string x3="Íàñòðîéêè MACD SMA:";
extern int smaper=3;

extern string x4="Íàñòðîéêè RSI:";
extern int rsiper=21;
extern int rsiur=50;

extern string x5="Íàñòðîéêè ñèëû äâèæåíèÿ:";
extern int sila=100;

extern string x6="Íàñòðîéêè ParabolicSar:";
extern double step=0.02;
extern double maximum=0.2;

extern string x7="Íàñòðîéêè âûáîðà StopLoss:";
extern bool StopLossParabolic=false;
extern bool StopLossEMA=true;
extern int otstup=0;

extern string x8="Íàñòðîéêè âûáîðà TakeProfit:";
extern bool TakeProfitParabolic=true;
extern bool TakeProfitRSI=true;
extern int rsitpurbuy=65;
extern int rsitpursell=35;


int maxdrow=24250;
double macd[1000];
int start()
  {
  
        NatusPro4HStrClassicPattern();
        NatusPro4HStrPosManager();

   return(0);
  }
int buy,sell,i,flagtest,wait,waits;int nummodb,nummods;
int NatusPro4HStrClassicPattern()
{  double sl;
     buy=0;sell=0;
     for(int  i=0;i<OrdersTotal();i++)
         {
           OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
           if(OrderType()==OP_BUY ){buy=1;}
           if(OrderType()==OP_SELL ){sell=1;}
         }  
         
 double ema13 =iMA(NULL,0,perema1,0,MODE_EMA,PRICE_CLOSE,1);
 double ema21 =iMA(NULL,0,perema2,0,MODE_EMA,PRICE_CLOSE,1);
 double sma55 =iMA(NULL,0,persma3,0,MODE_EMA,PRICE_CLOSE,1);
 
 //double looker=iCustom(NULL, 0, "NatusekoProtrader4HStrategy",1,1);
 
        ArraySetAsSeries(macd,true);
        for( i=10; i>=0; i--)          
        {
        macd[i]=iMACD(NULL,0,lowema4,fastema4,1,PRICE_CLOSE,MODE_MAIN,i);
        }
        
        if(i<=1)
        {     
             double bbmain=iBandsOnArray(macd,0,bbper,bbotcl,0,MODE_MAIN,1);
             double bbup=iBandsOnArray(macd,0,bbper,bbotcl,0,MODE_UPPER,1);
             double bblow=iBandsOnArray(macd,0,bbper,bbotcl,0,MODE_LOWER,1);
             double macdsma=iMAOnArray(macd,0,smaper,0,MODE_SMA,1);
         }
         
         double rsi=iRSI(NULL,0,rsiper,PRICE_CLOSE,1);
         double pb=iSAR(NULL,0,step,maximum,1);
         
         double high=MathAbs(High[1]-Close[1]);  
         double telo=MathAbs(Close[1]-Open[1]); 
         double low=MathAbs(Open[1]-Low[1]); 
         
         
  if(ema13>ema21 && ema13>sma55 && rsi>rsiur && rsi<rsitpurbuy &&macd[1]>macdsma && macd[1]>bbmain && macdsma>bbmain && telo>0 && telo>low && telo>high && pb<Close[1]&& buy==0)
  {
   if((Close[1]-sma55)<sila*Point)
   {if(StopLossParabolic==true){sl=pb-otstup*Point;}if(StopLossEMA==true){sl=sma55-otstup*Point;}
   OrderSend(Symbol(),OP_BUY,0.1,Ask,3,NormalizeDouble(sl,4),0,"FORTRADER.RU",0,0,Red);
   nummodb=0;
   }
   else{wait=1;}
  }
  
  if(Low[1]<=ema13 && rsi<rsitpurbuy && pb<Close[1] && wait==1&& buy==0)
      {if(StopLossParabolic==true){sl=pb-otstup*Point;}if(StopLossEMA==true){sl=sma55-otstup*Point;}
         OrderSend(Symbol(),OP_BUY,0.1,Ask,3,NormalizeDouble(sl,4),0,"FORTRADER.RU",0,0,Red);
         nummodb=0;
         wait=0;
      }
  
  
  /******************************************************************************************************************************************/
  if(ema13<ema21 && ema13<sma55 && rsi<rsiur && rsi>rsitpursell &&macd[1]<macdsma && macd[1]<bbmain && macdsma<bbmain && telo>0 && telo>low && telo>high && pb>Close[1]&& sell==0)
  {
   if((sma55-Close[1])<sila*Point)
   {if(StopLossParabolic==true){sl=pb+otstup*Point;}if(StopLossEMA==true){sl=sma55+otstup*Point;}
   OrderSend(Symbol(),OP_SELL,0.1,Bid,3,NormalizeDouble(sl,4),0,"FORTRADER.RU",0,0,Red);
   nummods=0;
   }
   else{waits=1;}
  }
  
  if(High[1]>=ema13 && rsi>rsitpursell && pb>Close[1] && waits==1&& sell==0)
      {if(StopLossParabolic==true){sl=pb+otstup*Point;}if(StopLossEMA==true){sl=sma55+otstup*Point;}
         OrderSend(Symbol(),OP_SELL,0.1,Bid,3,NormalizeDouble(sl,4),0,"FORTRADER.RU",0,0,Red);
         nummods=0;
         waits=0;
      }
  
 /******************************************************************************************************************************************/ 
}

int  NatusPro4HStrPosManager()
{double lt; 
double rsi=iRSI(NULL,0,rsiper,PRICE_CLOSE,1);
double pb=iSAR(NULL,0,step,maximum,1);
 
   for( i=1; i<=OrdersTotal(); i++)          
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) 
        {                                       
              if(OrderType()==OP_BUY && OrderProfit()>5 && rsi>rsitpurbuy && TakeProfitRSI==true && OrderSymbol()==Symbol() && nummodb==0)
              {  lt=NormalizeDouble(OrderLots()/2,2);if(lt<=0.01){lt=0.01;}
                 OrderClose(OrderTicket(),lt,Bid,3,Violet); 
                 nummodb++;
              }
         }
             
         if (OrderSelect(i-1,SELECT_BY_POS)==true) 
            {  
              if(OrderType()==OP_BUY && OrderProfit()>5 && pb>Close[1] && TakeProfitParabolic==true &&OrderSymbol()==Symbol() && nummodb==0)
              { lt=NormalizeDouble(OrderLots()/2,2);if(lt<=0.01){lt=0.01;}
                 OrderClose(OrderTicket(),lt,Bid,3,Violet); 
                 nummodb++;   
              }
             }
             
            if (OrderSelect(i-1,SELECT_BY_POS)==true) 
            {  
              if(OrderType()==OP_BUY && OrderProfit()>5 && rsi<rsiur  &&OrderSymbol()==Symbol())
              { 
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
              }
             }
             
          
             
             /**********************************************************************************************************************************/
             
            if (OrderSelect(i-1,SELECT_BY_POS)==true) 
            { 
              
              if(OrderType()==OP_SELL && OrderProfit()>5 && rsi<rsitpursell && TakeProfitRSI==true  &&OrderSymbol()==Symbol() && nummods==0)
              {lt=NormalizeDouble(OrderLots()/2,2);if(lt<=0.01){lt=0.01;}
               OrderClose(OrderTicket(),lt,Ask,3,Violet); 
               nummods++; 
              }
            }
             
        if (OrderSelect(i-1,SELECT_BY_POS)==true) 
        { 
              if(OrderType()==OP_SELL && OrderProfit()>5 && pb<Close[1] && TakeProfitParabolic==true &&  OrderSymbol()==Symbol() && nummods==0)
              {  lt=NormalizeDouble(OrderLots()/2,2);if(lt<=0.01){lt=0.01;}
                 OrderClose(OrderTicket(),lt,Ask,3,Violet); 
                 nummods++;
                  
              }
        }
      
                 if (OrderSelect(i-1,SELECT_BY_POS)==true) 
            {  
              if(OrderType()==OP_SELL && OrderProfit()>5 && rsi>rsiur  &&OrderSymbol()==Symbol())
              { 
                 OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); 
              }
             }
 }
 

 
 
}



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains the highest prices of each bar
Series array that contains open prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Indicators Used:

Moving average indicator
MACD Histogram
Relative strength index
Parabolic Stop and Reverse system


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders

It automatically opens orders when conditions are reached
It Closes Orders by itself

Other Features:

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.57 Total Net Profit:-184.50

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.58 Total Net Profit:-119.54

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.80 Total Net Profit:-122.40

BackTest : USDCAD on H1

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

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:1.03 Total Net Profit:3.81

Request Backtest for NatusekoProtrader4HStrategy


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

Pair: Period: