Help with ADX

 

I dont know but i guess ADX indicator has no fixed marginal limit between to move like stochastic or rsi.My problem is that i've set up a setting where it will only take trades if ADX>50 and it wont work it will take trades whenever it wants even below the preset 50 level.But if i set a value like ADX>99 then it wont take trades.It very confusing and annoying i need help please.Here is my code:

extern int ADX_PERIOD=14;
extern double ADX_LIMIT_TRIGGER=50;
double ADXTREND = iADX(Symbol(),0,ADX_PERIOD,PRICE_CLOSE,MODE_MAIN,0);
if(FMA1>FMA2 && FMA2>FMA3 && FMA3>FMA4 && FMA4>FMA5 && FMA5>FMA6 && FMA6>FMA7 && FMA7>FMA8 && FMA8>FMA9 && FMA9>FMA10 && FMA10>FMA11 && ADXTREND>ADX_LIMIT_TRIGGER)
buy=true;
if(FMA1<FMA2 && FMA2<FMA3 && FMA3<FMA4 && FMA4<FMA5 && FMA5<FMA6 && FMA6<FMA7 && FMA7<FMA8 && FMA8<FMA9 && FMA9<FMA10 && FMA10<FMA11 && ADXTREND>ADX_LIMIT_TRIGGER)
sell=true;

Just ignore FMA-s those are my moving averages.The problem is with ADX...

Also wrote a Print function to show me what values it takes the ADX,and it shows normal values 13.562, 30.123, 24.245,... and idk why the heck it cant realize that 50 is bigger than those?

 
Proximus:

But if i set a value like ADX>99 then it wont take trades.It very confusing and annoying i need help please.

How often have you seen value ADX>99

can you show picture of EURUSD chart with ADX period 14 where value has become > 99

 

I suggest try these lines without the FMAs

if(ADXTREND>ADX_LIMIT_TRIGGER)
buy=true;
if(ADXTREND>ADX_LIMIT_TRIGGER)
sell=true;

or this way:

if((FMA1>FMA2) && (FMA2>FMA3) && (FMA3>FMA4) && (FMA4>FMA5) && (FMA5>FMA6) && (FMA6>FMA7) && (FMA7>FMA8) && (FMA8>FMA9) && (FMA9>FMA10) && (FMA10>FMA11)
 && (ADXTREND>ADX_LIMIT_TRIGGER))
buy=true;

and the same for sell. What is the result?

I am not sure this will solve the problem, I remember conditions like this may confuse code interpretation.

 
deVries:

How often have you seen value ADX>99

can you show picture of EURUSD chart with ADX period 14 where value has become > 99


Not the ADX value but the trigger,which below it should not take trades.I set it to 99 so ADX below 99 will not take trades.Yes it is rare but only to check it.So if i put it to 50 to not take trades below 50, it will take trades below it even at ADX 10,thats the problem.I dont want it to take trades below the
ADX_LIMIT_TRIGGER
Variable
szgy74:

I suggest try these lines without the FMAs

or this way:

and the same for sell. What is the result?

I am not sure this will solve the problem, I remember conditions like this may confuse code interpretation.


Here is the pic it can be clearly seen that the adx (teal line,not the dashed line) is around ~23-35 and the limit is set to 50 here,so under 50 it should not take trades and yet it did some buy trades...

The FMA-s are my moving averages, it works perfectly without the ADX actually,but i need to implement an ADX to the strategy
 
Proximus:

Here is the pic it can be clearly seen that the adx is around ~23 and the limit is set to 30 here,so under 30 it should not take trades and yet it did a buy trade...



OK. I tried the simple version of the condition ( if(ADXTREND>ADX_LIMIT_TRIGGER) ) and I have no problem with it.


Just a simple question: are the booleans buy and sell set to false _before_ your condition?

 
szgy74:

OK. I tried the simple version of the condition ( if(ADXTREND>ADX_LIMIT_TRIGGER) ) and I have no problem with it.


Just a simple question: are the booleans buy and sell set to false _before_ your condition?


I wont work with (ADXTREND>ADX_LIMIT_TRIGGER) in ()

Just a simple question: are the booleans buy and sell set to false _before_ your condition?

No but it doesnt matter,since before the buy/sell order the conditions are tested again.

The problem must be with the ADX since before adding it to the EA it worked perfectly,but not its a mess.

 
Proximus:

I wont work with (ADXTREND>ADX_LIMIT_TRIGGER) in ()


As you want. Then I am finished here. Below is what I tested, I find no problem with adx or the condition.



int start()
{
   double ADXTREND = iADX(Symbol(),0,ADX_PERIOD,PRICE_CLOSE,MODE_MAIN,0);
   bool buy=false;
   bool sell=false;
   Print("ADX: ", ADXTREND, " --- ");
   if(ADXTREND>ADX_LIMIT_TRIGGER)
   {
      Print("ADX: ", ADXTREND, " --- BUY OR SELL TRIGGERED --- ");
      buy=true;
      sell=true;
   }
   return(0);
}
 
Proximus:

I wont work with (ADXTREND>ADX_LIMIT_TRIGGER) in ()



I don't understand why you ask for help and don't want to test/try the suggestions.


At least try and test the 2 parts separated like this below.



if((FMA1>FMA2) && (FMA2>FMA3) && (FMA3>FMA4) && (FMA4>FMA5) && (FMA5>FMA6) && (FMA6>FMA7) && (FMA7>FMA8) && (FMA8>FMA9) && (FMA9>FMA10) && (FMA10>FMA11))
{
        Print("FMA OK");
        if (ADXTREND>ADX_LIMIT_TRIGGER)
        {
                Print("ADX OK");
                buy=true;
        }
}
 
Proximus:

I dont know but i guess ADX indicator has no fixed marginal limit between to move like stochastic or rsi.My problem is that i've set up a setting where it will only take trades if ADX>50 and it wont work it will take trades whenever it wants even below the preset 50 level.But if i set a value like ADX>99 then it wont take trades.It very confusing and annoying i need help please.Here is my code:

Just ignore FMA-s those are my moving averages.The problem is with ADX...

Also wrote a Print function to show me what values it takes the ADX,and it shows normal values 13.562, 30.123, 24.245,... and idk why the heck it cant realize that 50 is bigger than those?

This value, for bar 0, changes during the formation of bar 0, yet your chart shows the value for the completed bar, what was the value when the trade was taken ? did you Print() it to the log ?

double ADXTREND = iADX(Symbol(), 0, ADX_PERIOD, PRICE_CLOSE, MODE_MAIN, 0);
 
RaptorUK:

This value, for bar 0, changes during the formation of bar 0, yet your chart shows the value for the completed bar, what was the value when the trade was taken ? did you Print() it to the log ?

Yes it has correct ADX values.It's not that the ADX has wrong values,but rather it will takes below the unwanted level of the ADX even if i ordered him not to.The filter was set to 50 so under 50 adx values it should not take any trade,but it does.And it doesnt really have any nearby 50 or higher values either,so its not because of the slippage...


Although i put a print() inside the test and it shows all values above 50,yet on the bar its below 50,how is this possible?

szgy74:


I don't understand why you ask for help and don't want to test/try the suggestions.


At least try and test the 2 parts separated like this below.




Tried this way too, it shows ADX OK and FMA OK but still take the trades...
 
Proximus:
Yes it has correct ADX values.It's not that the ADX has wrong values,but rather it will takes below the unwanted level of the ADX even if i ordered him not to.The filter was set to 50 so under 50 adx values it should not take any trade,but it does. And it doesnt really have any nearby 50 or higher values either,so its not because of the slippage...

How do you know this ? are you printing the ADX value when the trade is taken ? you can't see from the chart of a completed bar what the ADX value was while the bar was forming . . .
Reason: