ADXcrosses EA suggestion - page 2

 

As Ralph mentioned it is better to use the previous candle because the current candle can change on every tick mode.

The recommended way to enter using the ADX cross is when the ADX signal line is above 20 and rising and the previous high or the low is breached depending on whether it is a long cross or a short cross.

When the ADX signal line is rising and above 20, it signifies the market is trending.

Works better in 4 Hour and higher time frames.

If the ADX signal line is very high the market is considered overheated.

If the ADX hooks down on those high levels it is sign to take partial profits or close all the positions, depending on risk tolerance. Some consider above 40 is high, while others consider above 70 is high.

 

I think you should follow mangman's advice as to how to use ADX (I sure don't know much about that).

Anyhow, the following code snippet would be a way to fit in the indicator into your EA instead of the iCustom calls, and then to implement the logic in a corrected way:

//-- Use ADX crosses and derivative considering closes of bar 1 and 2

//-- Note that close of bar 1 has just happened.

double b4plusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, 2);

double nowplusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, 1);

double b4minusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_MINUSDI, 2);

double nowminusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_MINUSDI, 1);

//----

if ( b4plusdi > b4minusdi && nowplusdi < nowminusdi )

value1 = Low[1] - nShift*Point;

//----

if ( b4plusdi nowminusdi )

value2 = High[1] + nShift*Point;

Through that logic, the crossing is detected by the EA (repeatedly) during the bar that follows the bar during which the crossing occured.

Yet, in your chart, the deal is that the three arrows have been placed there after the fact and not before. The "i-1" in your indicator code points at "the bar following bar i" and not "the bar preceding bar i", which would have been called "i+1". Thus, the indicator marks a bar by considering data that is later than the marked bar, so it really says "Hey, big man: here you missed a trade (2 hours ago)!" rather than "Hey, big man: now you should trade!"..... a "Just Too Late" indicator

The "corrected" logic above will fire at the earliest with the first tick of the second bar to the right of the arrows on your chart. This firing is on the bar immediately following the one where the crossing occurs, which is as early as it gets.

To make it earlier, the EA will have to predict crossings rather than discover them, and consider the probability of it being played out etc. By such logic, you may get it to fire before the crossing, but possibly falsely (as you already discovered). Referring to close of bar 0 from the indicator is basically to ask it to predict, where it does so by assuming that the price right now is going to be the close price.

 

thanks again to ralf and mangman, you are very helpfull!

i tryed a lot of combinations but it doesn't matter what i do - the profit isn't as high as the real indi does

maybe i could run the EA only one time once a new candle is born

( ex. with "Close[]" or "iclose()" )

or is there any other function wich works similar but simpler to use?

THANK YOU !!!

Reason: