Indicators: TDI

 

TDI:

The Trend Detection Index. It has two parameters:
  • Period - calculation period;
  • Applied price - price used for calculations.

Possible interpretation of the indicator

  • If the histogram points upwards, buying is preferred; if downwards — selling is preferred.
  • The intersection of the TD Index and Direction lines, intersection of Direction and zero, as well as a change in direction can also be a signal to open a position in the direction indicated by the histogram.
  • If trading implies opening of counter-trend positions (trading on rollbacks), then a change in the line direction counter to the histogram direction can serve as a signal to open a counter-trend position.

Author: Scriptor

 

Incorrect indicator behaviour on some symbols was noticed (histogram is not drawn). Correction here:

Forum on trading, automated trading systems and testing trading strategies

Expert Advisors: TDI EA

Artyom Trishkin, 2020.01.06 05:45 AM

Do this:

//--- Calculating the indicator
   for(int i=limit; i>=0 && !IsStopped(); i--)
     {
      BufferDIR[i]=MAOnArray(BufferMom,0,period_ma,0,MODE_SMA,i)*period_ma;
      double F=fabs(BufferDIR[i]);
      double H=MAOnArray(BufferMomAbs,0,period_ma,0,MODE_SMA,i)*period_ma;
      double G=MAOnArray(BufferMomAbs,0,2*period_ma,0,MODE_SMA,i)*2*period_ma;
      BufferTDI[i]=F+H-G;
      //---
      if(BufferTDI[i]>0)
         BufferSIG[i]=(BufferDIR[i]>0 ? -fabs(BufferDIR[i]) : fabs(BufferDIR[i]));
      else
         BufferSIG[i]=BufferSIG[i+1];
      BufferColors[i]=(BufferSIG[i]>0 ? 0 : 1);
     }

There too small values are set for the histogram on some symbols:

BufferSIG[i]=(BufferDIR[i]>0 ? -0.1 : 0.1);

 

Looks like the histogram is pointing the wrong way.

22