Using an ADX filter

 

I am developing an EA and have already programmed a number of tests for entry.

When these tests give a Buy or Sell signal, I want to filter the signal through ADX.

Here is the code I propose...

bool ADX_filter(int type=0)
{
   bool result=false;
   double ADXminus = iADX(Symbol(),0,ADX,PRICE_OPEN,MODE_MINUSDI,0);
   double ADXplus = iADX(Symbol(),0,ADX,PRICE_OPEN,MODE_PLUSDI,0);
   double ADXmain = iADX(Symbol(),0,ADX,PRICE_OPEN,MODE_MAIN,0);

   if( type==1 ) // Buy
   {
      if( ADXplus>ADXfactor*ADXminus && ADXmain>=20 && ADXmain<=40 ) result=true;
   }
   
   if( type==-1 ) // Sell
   {
      if( ADXminus<ADXplus/ADXfactor && ADXmain>=20 && ADXmain<=40 ) result=true;
   }
   return(result);
}

"type" is 1 if a Buy signal has been generated or -1 if a Sell signal.

Externally, ADX is set to 25 and ADXfactor is subject to optimization, starting with 1 and growing to 1.4.

The filter has improved the performance of the EA on EURUSD M15 but back testing took a long time.

I wonder if anyone might be able to use the filter in their EA and let me know the results?

Thank you, fantastic forum, Helmut

 
engcomp wrote >>

I am developing an EA and have already programmed a number of tests for entry.

When these tests give a Buy or Sell signal, I want to filter the signal through ADX.

Here is the code I propose...

"type" is 1 if a Buy signal has been generated or -1 if a Sell signal.

Externally, ADX is set to 25 and ADXfactor is subject to optimization, starting with 1 and growing to 1.4.

The filter has improved the performance of the EA on EURUSD M15 but back testing took a long time.

I wonder if anyone might be able to use the filter in their EA and let me know the results?

Thank you, fantastic forum, Helmut


Helmut

Have you looked at the Vortex indicator? I have found that although ADX DI+ and DI- gives good buy-sell signals, Vortex is approx 25% more accurate.

Barry

Files:
 
ForexID10T:


Helmut

Have you looked at the Vortex indicator? I have found that although ADX DI+ and DI- gives good buy-sell signals, Vortex is approx 25% more accurate.

Barry



Thank you, Barry

Yes, I looked at it and it seems superior to the +DI and -DI.

I still have to use ADX because VortexIndicator appears to have no equivalent.

Can I use VortexIndicator in my EA without infringing the copyright of anybody?

Regards, Helmut

Reason: