TDI_v3





//+------------------------------------------------------------------+
//|                                                          TDI.mq4 |
//|                                       Copyright © 2009, WalkMan. |
//|                                                                  |
//+------------------------------------------------------------------+
//|  Price & Line Type settings:                                     |                
//|   RSI Price settings                                             |               
//|   0 = Close price     [DEFAULT]                                  |               
//|   1 = Open price.                                                |               
//|   2 = High price.                                                |               
//|   3 = Low price.                                                 |               
//|   4 = Median price, (high+low)/2.                                |               
//|   5 = Typical price, (high+low+close)/3.                         |               
//|   6 = Weighted close price, (high+low+close+close)/4.            |
//|                                                                  |
//|   RSI Price Line & Signal Line Type settings                     |
//|   0 = Simple moving average       [DEFAULT]                      |
//|   1 = Exponential moving average                                 |
//|   2 = Smoothed moving average                                    |
//|   3 = Linear weighted moving average                             |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, WalkMan."
#property link      ""
bool Work=true;                    // Ýêñïåðò áóäåò ðàáîòàòü.
extern double Lots = 0.01;
extern int RSI_Period = 13;         //8-25
extern int RSI_Price = 0;           //0-6
extern int Volatility_Band = 34;    //20-40
extern int RSI_Price_Line = 2;      
extern int RSI_Price_Type = 0;      //0-3
extern int Trade_Signal_Line = 7;   
extern int Trade_Signal_Type = 0;   //0-3
extern int slippage = 0;
extern int magic = 123456;
static int prevtime = 0;
static int Sell = 0;
static int Buy = 0;

int init()
  {
     prevtime = Time[0];
   return(0);
}


int deinit()
  {


   return(0);
  }


int start()
  {
  
if (! IsTradeAllowed()) {
      return(0);
   }
   
      if(Work==false)                              // Êðèòè÷åñêàÿ îøèáêà
     {
      Alert("Êðèòè÷åñêàÿ îøèáêà. Ýêñïåðò íå ðàáîòàåò.");
      return;                                   // Âûõîä èç start()
     }  
   
   if (Time[0] == prevtime) {
      return(0);
   }
   prevtime = Time[0];
   
   
 /*  
   Print("Buy =", Buy);
   Print("Sell =", Sell);
   */
   
double RSI = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 0);
double RSI1 = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 1);
double HighLine = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 1, 0);
double HighLine1 = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 1, 1);
double LowLine = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 3, 0);
double LowLine1 = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 3, 1);
double BLine = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 2, 0);
double BLine1 = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 2, 1);
double Signal = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 5, 0);
double Signal1 = iCustom(NULL, 0, "Traders_Dynamic_Index", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 5, 1);

//

if(RSI1>HighLine1 && RSI<HighLine && OrderType()!=OP_SELL && OrdersTotal()<=1)
 {
  Sell=Sell+3;
 } 

if(RSI1<LowLine1 && RSI>LowLine && OrderType()!=OP_BUY && OrdersTotal()<=1)
 {
  Buy=Buy+3;
 }

if(RSI1<Signal1 && RSI>Signal && OrderType()!=OP_BUY && OrdersTotal()<=1)
 {
  Buy=Buy+2;
 }

if(RSI1>Signal1 && RSI<Signal && OrderType()!=OP_SELL && OrdersTotal()<=1)
 {
  Sell=Sell+2;
 }

if(RSI1<BLine1 && RSI>BLine && OrderType()!=OP_BUY && OrdersTotal()<=1)
 {
  Buy=Buy+3;
 }

if(RSI1>BLine1 && RSI<BLine && OrderType()!=OP_SELL && OrdersTotal()<=1)
 {
  Sell=Sell+3;
 }
     
   int ticket = -1;
   int total = OrdersTotal();
   for (int i = total - 1; i >= 0; i--) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == magic)) {
         int prevticket = OrderTicket();
             if (Buy >= 5)
    {
     OrderClose(prevticket,OrderLots(),Ask,3,Red);
    }

   if (Sell>= 5)
    {
     OrderClose(prevticket,OrderLots(),Bid,3,Blue);
    }  
        return(0);
      }
   }

          if (Sell >= 5 && OrdersTotal()==0)
           {
            ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,0,0, WindowExpertName(), magic, 0, Red);
            Sell=0;
           }
          if (Buy >= 5  && OrdersTotal()==0)
           {
            ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,0,0,WindowExpertName(), magic, 0, Blue);
            Buy=0;
           }

   return(0);
  }






Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:




Custom Indicators Used:
Traders_Dynamic_Index

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:

It issuies visual alerts to the screen

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:1.16 Total Net Profit:23.97

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:1.12 Total Net Profit:15.54

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.39 Total Net Profit:-69.47

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.82 Total Net Profit:-35.05

BackTest : GBPUSD on H1

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

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.70 Total Net Profit:-398.17

BackTest : USDCAD on H1

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

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.63 Total Net Profit:-23.00

Request Backtest for TDI_v3


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

Pair: Period: