ZigZagEvgeTrofi 1





//+------------------------------------------------------------------+
//|                                            ZigZagEvgeTrofi 1.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Trofimov Evgeniy"
#property link      "http://www.fracpar.narod.ru/"

#define MAGICMA  20080919
#define Slippage 5

//---- indicator parameters
extern int ExtDepth=17; //10-21 !15 !17
extern int ExtDeviation=7; //!7
extern int ExtBackstep=5;  //!5
extern double Lot=0.10;
//----
static int prevtime = 0;
int Urgency=2;
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   int i, candle;
   double ZigZag;
   int CurrentCondition, Signal;
   
   if (! IsTradeAllowed()) {
      prevtime = Time[1];
      MathSrand(TimeCurrent());
      Sleep(30000 + MathRand());
      return(0);
   }
   if (Time[0] == prevtime) return(0);
   prevtime = Time[0];  
   while(candle<100)
     {
      ZigZag=iCustom(NULL,0,"ZigZag",   ExtDepth,ExtDeviation,ExtBackstep,   0,candle);
      if(ZigZag!=0) break;
      candle++;
     }
   if(candle>99) return(0);
   if(ZigZag==High[candle])
      Signal=1;
   else if(ZigZag==Low[candle])
      Signal=2;
   int total = OrdersTotal();
   for (i = 0; i < total; i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGICMA) {
         CurrentCondition=OrderType()+1;
         break;
      } 
   }
   
   if(Signal==CurrentCondition) return(0);
   if(Signal!=CurrentCondition && CurrentCondition>0)
     {
      if(CurrentCondition==1)
         OrderClose(OrderTicket(),OrderLots(),Bid,Slippage);
      else
         OrderClose(OrderTicket(),OrderLots(),Ask,Slippage);
      Sleep(20000);
      RefreshRates();
     }

   if(candle<=Urgency)
     {
      if(Signal==1)
         OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, 0, 0, "ZigZag", MAGICMA, 0, Blue);
      else
         OrderSend(Symbol(), OP_SELL, Lot, Bid, Slippage, 0, 0, "ZigZag", MAGICMA, 0, Red);
      Sleep(20000);
      prevtime = Time[1];
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
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:
ZigZag

Order Management characteristics:
Checks for the total of open orders

It Closes Orders by itself
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.54 Total Net Profit:-745.36

BackTest : EURUSD on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.75 Total Net Profit:-192.47

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.65 Total Net Profit:-479.80

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:2.21 Total Net Profit:408.96

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:1.04 Total Net Profit:60.61

BackTest : GBPUSD on H1

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

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.90 Total Net Profit:-968.18

BackTest : USDCAD on H1

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

BackTest : USDCHF on H1

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

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.82 Total Net Profit:-91.02

Request Backtest for ZigZagEvgeTrofi 1


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

Pair: Period: