starter_euraud_diapazon_time_zatiag





//+------------------------------------------------------------------+
//|                                                      Starter.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#define MAGICMA  20050610

extern double Lots               = 1;
extern double MaximumRisk        = 0.053;
extern double DecreaseFactor     = 5000;
//extern double Lots = 4;
extern double Stop = 1;
extern double MAPeriod=11;
extern double Lm = 0.14;
extern double Lb = 0.86;
double spread=1.5;
//+-- extern double JuiceLevel = 0.0005;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
 
//+------------------------------------------------------------------+
//| Calculate optimal lot size                                       |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/500,1);
//---- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//---- return lot size
   if(lot<1) lot=1;
   if(lot>100) lot=100;
   return(lot);
  }  
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   double Laguerre;
   double Alpha;
   double MA, MAprevious;
   
//+--   double Juice;
   int cnt, ticket, total, cmo;
  
  Laguerre=iCustom(NULL, 0, "Laguerre", 0, 0);
  Alpha=iCCI(NULL, 0, 14, PRICE_CLOSE, 0);
  MA=iMA(NULL,0,MAPeriod,0,MODE_EMA,PRICE_MEDIAN,0);
  MAprevious=iMA(NULL,0,MAPeriod,0,MODE_EMA,PRICE_MEDIAN,1);
//+--  Juice=iCustom(NULL,0,"Juice",0,0);
  
  total=OrdersTotal();
   if(total<1) 
     {
      // no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if((Laguerre<Lm) && (MA>MAprevious) && (Alpha<-5) && (Hour()>6)) //+-- && Juice>JuiceLevel)
        {
        ticket=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"starter",16384,0,Green);
        }
      // check for short position (SELL) possibility
      if((Laguerre>Lb) && (MA<MAprevious) && (Alpha>5) && (Hour()>6)) //+-- && Juice>JuiceLevel)
        {
         ticket=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"starter",16384,0,Red);
        } 
     }
// it is important to enter the market correctly, 
   // but it is more important to exit it correctly...   
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            if(((CurTime()-OrderOpenTime())>1800) && (Bid-OrderOpenPrice()<=0))
              {
                OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                Print(CurTime(), " - ", OrderOpenTime(), " = ", (CurTime()-OrderOpenTime()));
                return(0); // exit  
              }
            // should it be closed?
            if(Laguerre>Lb)
               {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                 return(0); // exit
               }
            // check for stop
            if(Stop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*Stop)
                 {
                   OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                   return(0);
                 }
              }
           }
         else // go to short position
           {
            if(((CurTime()-OrderOpenTime())>1800) && (OrderOpenPrice()-Ask<=0))
              {
                OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                Print(CurTime(), " - ", OrderOpenTime(), " = ", (CurTime()-OrderOpenTime()));
                return(0); // exit  
              }
            // should it be closed?
            if(Laguerre<Lm)
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               return(0); // exit
              }
            // check for stop
            if(Stop>0)  
              {                 
               if(OrderOpenPrice()-Ask>Point*Stop)
                 {
                   OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                   return(0);
                 }
              }
           }
        }
     }
     
   return(0);
  }
// the end.



Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:


Commodity channel index
Moving average indicator


Custom Indicators Used:
Laguerre

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:10.69 Total Net Profit:6813.52

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:4.90 Total Net Profit:2008.80

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:11.48 Total Net Profit:1982.80

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.30 Total Net Profit:-2675.40

BackTest : GBPUSD on H1

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

BackTest : USDCAD on H1

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

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.40 Total Net Profit:-297.73

Request Backtest for starter_euraud_diapazon_time_zatiag


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

Pair: Period: