Author: Copyright � 2009, WalkMan.
Profit factor:
0.76

Okay, here's a breakdown of what this MetaTrader script does, explained in a way that doesn't require any programming knowledge:

Overall Goal:

This script is designed to automatically place buy and sell orders in the Forex market based on signals from a specific technical indicator called the "Traders Dynamic Index" (TDI). Think of it as an automated trading assistant that tries to identify potentially profitable trading opportunities.

Here's how it works step-by-step:

  1. Setup and Configuration:

    • The script starts by reading in some settings that you, the user, can customize. These settings control how the TDI indicator is calculated and how the script should behave. Key settings include:
      • Lots: The size of the trades it will place (e.g., 0.01 means a small trade).
      • RSI_Period, Volatility_Band, etc.: These are settings that fine-tune the TDI indicator itself. The TDI indicator consists of the RSI combined with bands to identify the volatility of the market, which in this case is named Volatility band.
      • slippage: A buffer to allow for slight price changes when placing an order.
      • magic: a unique identification number so the script only manages its own trades.
  2. Checking the Environment:

    • The script makes sure it's allowed to trade and that it's not trying to do things too quickly. It only runs once per price update to avoid overloading the system.
  3. Reading the TDI Indicator:

    • The heart of the script is using the Traders Dynamic Index. This indicator generates several lines and levels based on historical price data and calculations. The script retrieves these values:

      • RSI: The main RSI line of the TDI.
      • Signal: a Signal Line of the TDI to check crossover events.
      • HighLine, LowLine: These are upper and lower bands or levels that the TDI indicator uses.
      • BLine: another line from the TDI indicator to compare against the RSI line.
    • The script retrieves the current value of these lines and also the value of the previous time period using RSI1,Signal1, HighLine1, LowLine1, BLine1.

  4. Generating Buy/Sell Signals:

    • The script compares the current values of the TDI lines to the previous ones and to each other. It is looking for specific patterns where the RSI line crosses above or below other lines of the TDI.

    • It then assigns a score to either a "Buy" or "Sell" indicator depending on the crosses.

  5. Managing Existing Trades (if any):

    • The script checks if it already has any open trades. If the "Buy" or "Sell" scores reach a certain level (5), it will close the existing trade.
  6. Placing New Trades:

    • If the "Buy" score reaches 5 and there are no open trades, the script will automatically place a "Buy" order.
    • If the "Sell" score reaches 5 and there are no open trades, the script will automatically place a "Sell" order.
    • After placing a trade, the "Buy" and "Sell" scores are reset to zero.

In Simple Terms:

The script watches a special indicator (TDI). When the TDI lines create certain crossing patterns that suggest a potential upward or downward price movement, the script either buys or sells automatically. It also closes any existing trades if the indicator suggests the market is moving in the opposite direction.

Important Note: This script is based on a specific trading strategy (TDI indicator) and relies on certain assumptions about market behavior. It's crucial to understand the TDI indicator and the risks involved before using this script to trade with real money.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Miscellaneous
It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
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);
  }


Profitability Reports

USD/CHF Jul 2025 - Sep 2025
0.60
Total Trades 123
Won Trades 48
Lost trades 75
Win Rate 39.02 %
Expected payoff -0.46
Gross Profit 86.73
Gross Loss -143.39
Total Net Profit -56.66
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.69
Total Trades 138
Won Trades 57
Lost trades 81
Win Rate 41.30 %
Expected payoff -0.19
Gross Profit 58.83
Gross Loss -84.86
Total Net Profit -26.03
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.29
Total Trades 127
Won Trades 30
Lost trades 97
Win Rate 23.62 %
Expected payoff -0.92
Gross Profit 46.93
Gross Loss -164.34
Total Net Profit -117.41
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.93
Total Trades 140
Won Trades 66
Lost trades 74
Win Rate 47.14 %
Expected payoff -0.08
Gross Profit 140.61
Gross Loss -151.27
Total Net Profit -10.66
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.55
Total Trades 153
Won Trades 46
Lost trades 107
Win Rate 30.07 %
Expected payoff -0.48
Gross Profit 89.35
Gross Loss -163.45
Total Net Profit -74.10
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.78
Total Trades 128
Won Trades 57
Lost trades 71
Win Rate 44.53 %
Expected payoff -0.26
Gross Profit 117.69
Gross Loss -150.72
Total Net Profit -33.03
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 15
Won Trades 3
Lost trades 12
Win Rate 20.00 %
Expected payoff -703.31
Gross Profit 4.30
Gross Loss -10553.93
Total Net Profit -10549.63
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.12
Total Trades 152
Won Trades 68
Lost trades 84
Win Rate 44.74 %
Expected payoff 0.07
Gross Profit 91.74
Gross Loss -81.86
Total Net Profit 9.88
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.69
Total Trades 293
Won Trades 122
Lost trades 171
Win Rate 41.64 %
Expected payoff -0.54
Gross Profit 347.51
Gross Loss -506.69
Total Net Profit -159.18
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.81
Total Trades 302
Won Trades 116
Lost trades 186
Win Rate 38.41 %
Expected payoff -0.26
Gross Profit 326.53
Gross Loss -405.59
Total Net Profit -79.06
-100%
-50%
0%
50%
100%

Comments