Best indicator combo?

 

I'm curious on your take of what you would consider the best indicator combo (especially those that can be used _OnArray). I've already read somewhere that you should use indicators that measure different things, like trend persistence, momentum, volatility, etc in combination, but not to use indicators that measure the same thing, like momentum, RSI and CCI together.

That being said, i read here about a method to use the RSI as a trend persistence indicator. I'm curious if anyone has had any success with it.

Would anyone consider the following combo a meaningful categorization scheme?

Momentum (>100, <100)

RSI trend (as described above)

Close[1] (>EMA, <EMA)

I know i left out the MACD, but wouldn't that give me something similar to the third criteria above? I'm also interested in indicators that can be calculated _OnArray.

 

That article refers to stock trading - different thing to Forex

Equities, commodities & Forex all have different characteristics - as the pairs are different within Forex

-BB-

 
So what would be a good indicator to suggest tending/non-trending?
 
gatornuke:
So what would be a good indicator to suggest tending/non-trending?

well detecting these is kind of a holy grail we all are looking to find. i have heard bollingerband and envelopes combination should work for that, but that depents. if band are inside the envelopes market is not trending, but you cannot say that the market will continue ranging with that method. most of the time you can say, the market was ranging

 
gatornuke:
So what would be a good indicator to suggest tending/non-trending?

Average Directional Movement Index (ADX) is a common trend strength indicator measuring price-movement over a certain period and direction.

You can check out some long term results I achieved with it here https://www.mql5.com/en/forum/127869.

/ McKeen

 

ADX, eh? I'll give it a shot. Too bad there's no ADX on array. Oh well, i guess i can stop being lazy and code something myself...

Thanks!

 

Ok, so i was hoping to see the code for ADX to figure out how to adapt it to my projected histories, but i guess that's only available for "custome indicators"

Could anyone confirm if MT4 calculates the ADX indicator in the following manner?

 
gatornuke:

Ok, so i was hoping to see the code for ADX to figure out how to adapt it to my projected histories, but i guess that's only available for "custome indicators"

Could anyone confirm if MT4 calculates the ADX indicator in the following manner?

Unfortunately I do not know if this is the exact formula used in the MT4 indicator equations.

But I see you have at least found all three formulas needed for all the lines.

Since I put the sand in your shoe here - if you don´t do it before me I will look into this tomorrow, since I consider it as a useful indicator and I might find use to integrate it into my own projects anyhow.

/ McKeen

 

Thanks. I noticed one of the options is "applied price" (PRICE_OPEN, PRICE_CLOSE, PRICE_HIGH, etc). I'm curious as to how this is used, since it surely will change the result. This is one of the reasons i was doubtful it was a straight copy and paste of that formula.

 
gatornuke:

Thanks. I noticed one of the options is "applied price" (PRICE_OPEN, PRICE_CLOSE, PRICE_HIGH, etc). I'm curious as to how this is used, since it surely will change the result. This is one of the reasons i was doubtful it was a straight copy and paste of that formula.

I actually found it in the codebase. Not 100% sure it is the same as the preinstalled with the client terminal but perhaps we can check it out.

https://www.mql5.com/en/code/7955

There were another 44 hits for adx in the code base so I am sure we´ll be making this without too much hussle.

/ McKeen

edit: I also found on another location the formula used for preinstalled adx indy main adx-line:

ADX = SUM[(+DI-(-DI))/(+DI+(-DI)), N]/N

meaning it differs from the equation you did find.. However it doesn´t mean that this or that would be any better...

 

Here is full ADX indicator source, not the same as preinstalled though as I can see this one does not have choice of PRICE_CLOSE, PRICE_OPEN etc. Looks really easy to implement though...

//+------------------------------------------------------------------+
//|                                                          ADX.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 YellowGreen
#property indicator_color3 Wheat
//---- input parameters
extern int ADXPeriod=14;
//---- buffers
double ADXBuffer[];
double PlusDiBuffer[];
double MinusDiBuffer[];
double PlusSdiBuffer[];
double MinusSdiBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(6);
//---- indicator buffers
   SetIndexBuffer(0,ADXBuffer);
   SetIndexBuffer(1,PlusDiBuffer);
   SetIndexBuffer(2,MinusDiBuffer);
   SetIndexBuffer(3,PlusSdiBuffer);
   SetIndexBuffer(4,MinusSdiBuffer);
   SetIndexBuffer(5,TempBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("ADX("+ADXPeriod+")");
   SetIndexLabel(0,"ADX");
   SetIndexLabel(1,"+DI");
   SetIndexLabel(2,"-DI");
//----
   SetIndexDrawBegin(0,ADXPeriod);
   SetIndexDrawBegin(1,ADXPeriod);
   SetIndexDrawBegin(2,ADXPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Average Directional Movement Index                               |
//+------------------------------------------------------------------+
int start()
  {
   double pdm,mdm,tr;
   double price_high,price_low;
   int    starti,i,counted_bars=IndicatorCounted();
//----
   i=Bars-2;
   PlusSdiBuffer[i+1]=0;
   MinusSdiBuffer[i+1]=0;
   if(counted_bars>=i) i=Bars-counted_bars-1;
   starti=i;
//----
   while(i>=0)
     {
      price_low=Low[i];
      price_high=High[i];
      //----
      pdm=price_high-High[i+1];
      mdm=Low[i+1]-price_low;
      if(pdm<0) pdm=0;  // +DM
      if(mdm<0) mdm=0;  // -DM
      if(pdm==mdm) { pdm=0; mdm=0; }
      else if(pdm<mdm) pdm=0;
           else if(mdm<pdm) mdm=0;
      //---- âû÷èñëÿåì èñòèííûé èíòåðâàë
      double num1=MathAbs(price_high-price_low);
      double num2=MathAbs(price_high-Close[i+1]);
      double num3=MathAbs(price_low-Close[i+1]);
      tr=MathMax(num1,num2);
      tr=MathMax(tr,num3);
      //---- counting plus/minus direction
      if(tr==0) { PlusSdiBuffer[i]=0; MinusSdiBuffer[i]=0; }
      else      { PlusSdiBuffer[i]=100.0*pdm/tr; MinusSdiBuffer[i]=100.0*mdm/tr; }
      //----
      i--;
     }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
//---- apply EMA to +DI
   for(i=0; i<=limit; i++)
      PlusDiBuffer[i]=iMAOnArray(PlusSdiBuffer,Bars,ADXPeriod,0,MODE_EMA,i);
//---- apply EMA to -DI
   for(i=0; i<=limit; i++)
      MinusDiBuffer[i]=iMAOnArray(MinusSdiBuffer,Bars,ADXPeriod,0,MODE_EMA,i);
//---- Directional Movement (DX)
   i=Bars-2;
   TempBuffer[i+1]=0;
   i=starti;
   while(i>=0)
     {
      double div=MathAbs(PlusDiBuffer[i]+MinusDiBuffer[i]);
      if(div==0.00) TempBuffer[i]=0;
      else TempBuffer[i]=100*(MathAbs(PlusDiBuffer[i]-MinusDiBuffer[i])/div);
      i--;
     }
//---- ADX is exponential moving average on DX
   for(i=0; i<limit; i++)
      ADXBuffer[i]=iMAOnArray(TempBuffer,Bars,ADXPeriod,0,MODE_EMA,i);
//----
   return(0);
  }
//+------------------------------------------------------------------+
Reason: