Divergence Indicator - page 27

To add comments, please log in or register
jetro1971
10
jetro1971  
poster:
Wildhog divergence wildhog-nrp-divergence.mq4

Hi poster,

This is one of the best divergence indicator that I've tested. Thanks.

However I face some problems calling it from expert by using iCustom(). I wonder if you have ever used it in an expert?

Let me explain briefly what I've faced:

the indicator uses 6 index buffers;

0--> wildhod (this holds the indicator value, no issues here)

1--> whda

2--> whdb

3--> Bullish Divergence

4--> Bearish Divergence

5--> slope

Issue-1) When there is a divergence (hidden or classical) it does not return any meaningful value to the buffers 3,4 or 1,2 even. expert does not understand when there is divergence and the direction of divergence.

Issue-2) The slope buffer is either 1 for up or -1 for down however it gets the value with 1 bar delay. As an example, you look to the indicator it gets green and up at 13:00 but the slope buffer became 1 at 14:00.

I would appreciate if you or someone would give a hand for these issues.

Thanks in advance

Robert
418
Robert  
jetro1971:
Hi poster,

This is one of the best divergence indicator that I've tested. Thanks.

However I face some problems calling it from expert by using iCustom(). I wonder if you have ever used it in an expert?

Let me explain briefly what I've faced:

the indicator uses 6 index buffers;

0--> wildhod (this holds the indicator value, no issues here)

1--> whda

2--> whdb

3--> Bullish Divergence

4--> Bearish Divergence

5--> slope

Issue-1) When there is a divergence (hidden or classical) it does not return any meaningful value to the buffers 3,4 or 1,2 even. expert does not understand when there is divergence and the direction of divergence.

Issue-2) The slope buffer is either 1 for up or -1 for down however it gets the value with 1 bar delay. As an example, you look to the indicator it gets green and up at 13:00 but the slope buffer became 1 at 14:00.

I would appreciate if you or someone would give a hand for these issues.

Thanks in advance

Hi Jetro1971...

Regarding your question 1) - no meaningful value in buffers...and your EA doesn't understand if it's a divergence or which direction..

To help check the indicator - I added Comments to see the all values in the Wildhog indicator...

And everything seems to be working fine in this indicator.

Since the indicator Comments show values...it must be how your EA is trying to get them.

We would need to see the EA code to help you troubleshoot and understand the problems you are having.

In the meantime...add Comments to your EA and display ALL the buffers from your indicator in your EA...and watch them closely.

Comments are your best best friend...!

Regarding your question 2) - slope buffer delay and color change.

If you watch the Wildhog indicator...very slowly...in the Strategy Tester...in a lower time frame so the divergences happens more often...

The indicator shows the slope colors reversing on the current bar (0) as the close price goes higher or lower than Bar1...

And then on the next bar...it locks the color on Bar1....

This is natural and not repainting. It would be repainting if Bar1 continues to change...

So the slope function appears to be working fine also.

Also a heads up on the divergence signal (both classic and hidden)...

Typically...divergence signals are normally confirmed on Bar2...to insure they are actually Top Peaks and Bottom Troughs...similar to pivots and zig zags...

This Wildhog shows divergence on Bar1...and it does flicker and repaint as Bar0 changes...and then the divergence line finally locks on Bar2.

So be careful with the divergence signal which needs to be confirmed with another indicator or strategy.

I have attached my test version of Wildhog with the Test Comments to help you in your efforts.

Good luck and have fun,

Robert

wildhog-nrp-divergence-_testcomments.mq4

jetro1971
10
jetro1971  

Hi Robert,

Thank you for your help and effort.

I think the indicator works fine however as you mentioned I could not get the right values from expert. I have included a simple ea that calls the Wildhog indicator. I'm trying to get for index 1 and print the values using alert to see it in the journal. I also add label print for the screen. Indicator prints the index 0 and ea prints index 1, I'm aware of this however when I check the bar time and output of the indicator, I cannot get meaningful results. Please see the picture.

And when I looked at your comment values, divergence variables are not inline with the indexbuffers of indicator. When you call the indicator it gets the value from indexbuffers. Do you think that there is a problem here as well?

Please try to check my ea in the attachment if you have time. You need to put the right filename. I'm using the standard inputs of the indicator does not change the inputs.

Thanks again

Robert
418
Robert  
jetro1971:
Hi Robert,

Thank you for your help and effort.

I think the indicator works fine however as you mentioned I could not get the right values from expert. I have included a simple ea that calls the Wildhog indicator. I'm trying to get for index 1 and print the values using alert to see it in the journal. I also add label print for the screen. Indicator prints the index 0 and ea prints index 1, I'm aware of this however when I check the bar time and output of the indicator, I cannot get meaningful results. Please see the picture.

And when I looked at your comment values, divergence variables are not inline with the indexbuffers of indicator. When you call the indicator it gets the value from indexbuffers. Do you think that there is a problem here as well?

Please try to check my ea in the attachment if you have time. You need to put the right filename. I'm using the standard inputs of the indicator does not change the inputs.

Thanks again

Hi Jet...

First a suggestion... You changed the name of the indicator - not a good thing - complicates the testing and problem-solving.

This is especially true when someone is trying to help you troubleshoot.

I had to spend time trying to find out what the "new problem" was...and I don't know if I am testing the same thing (I don't have that indicator/name)...

So...keep everything the same as much as possible...and don't change anything without documenting and telling what you changed.

Here's my discoveries and suggestions:

The main problem - you have a coding error in your "new-bar-time". It's a major error that MT4 did not find and log during compile.

EA values were NOT changing with the ticks... In watching the indicator values change every tick...the EA doesn't...

Problem:

// ######################### EVERY NEW BAR THE LOOP IS OPERATED ONCE ####################################

if (new_bar_time!= Time[0])

{ new_bar_time = Time[0];

Solution:

// ######################### EVERY NEW BAR THE LOOP IS OPERATED ONCE ####################################

if (new_bar_time!= Time[0])

new_bar_time = Time[0];

Second problem - your EA was getting Bar1 values...indicator is getting Bar0 values. They will never match.

I changed EA iCustom to Bar0....now the indicator and EA values match exactly.

Everything seems to be working fine with those changes.

One more suggestion...especially for testing...

Do not hard code the time frame in iCustom...leave it 0...

This is so you can drop it on lower time frames and see more happening faster... Hard to wait one hour to see changes...

Let us know how your adventures go with this Wildhog indicator and EA...

Hope this helps,

Robert

jetro1971
10
jetro1971  

Hi Robert,

Thank you again for your comments.

I changed the indicator name to make it short to call from icustom(). It's exactly the same indicator, same parameters, complied and copied to indicators directory. You can change the indicator name from expert as well.

If you move the parenthesis { from the code it would not compile. I don't want to get rid of from the loop since my aim is to get the index-1 values not index-0. Index 0 would change many times during H1 TF. I want to see the results after the bar is closed that's why I'm using the loop for "every bar". Besides if I don't use the loop, I cannot trace the values for index-1, index-2 etc. It would print many values to the journal.

You are right that comparing index-0 and index-1 would never be the same, may be it's my fault I couldn't explain my problem. I'm not interested in index-0. In the expert I print the wildhog values (buffers) to journal with Alert() function. In journal I can clearly see each value of indicator in index-1 index-2 index-3 matches with the indicator.

And when I compare with the indicator values only W0 matches others doesn't. When I see a divergence in the indicator say at index-1, the corresponding bar values w1,w2,w3,w4 does not give any signal that divergence occurs. Normally I would expect that the values change when there is divergence.

One more thing that I've asked you, the comments you put on the indicator are not inline with the indicator indexbuffers. May be the indexbuffers of the indicator are wrong (it does not change the indicator working). Because expert gets the values over indexbuffers. Could you please check this part as well?

BR/Jetro

Robert
418
Robert  

jetro1971

The parenthesis in that "if" place is wrong code...as far as I know...

Take a look at other EA's with the "if" statements and you will see there are NO parenthesis inside the "if" code syntax... They are put after that line to form the "if" block below it..

Try moving the parenthesis...AFTER...the Time[0]...and that should create the loop block you want for your Objects.

Also understood - you want index-1... Still should be no problem with what I've seen with the indicator so far.

And you said the indexes match...then you say...only W0 matches...I'm very confused...!

Better yet...show all your comparisons...because I don't yet fully understand what is being compared and why you think they are wrong?

It all seems to be working fine (at least the indicator side is).

You said: "One more thing that I've asked you, the comments you put on the indicator are not inline with the indicator index buffers."

I don't understand what this means.... "comments are....not inline with the index buffers"...?

I am using the indicator buffers exactly as they are listed in the indicator to display in Comments...

As far as I can see...the chart Comments values match exactly what the indicator shows in the subwindow...

Glad to see that you know how to add the Objects to show your values in your EA...

Really great help to easily see them on the chart...just one suggestion:

2147483647 is an "Empty Value" - convert this to 0 to make the empty values more readable on the chart:

Example - if (xx = 2147483647) xx = 0;

So in the meantime...unless a much better coder than me can help clarify these buffer problems with the EA and indicator...

I will assume the Wildhog indicator is working fine...and your EA should be getting any index's you want...

My only other suggestion at this point is...do more comparisons.

Use more Objects in your EA...and do a column comparison of your buffer values (maybe 3 bars back?)...

Then see where or why you are not getting what you want from the indicator.

Then share your results with us.

Good luck and take care,

Robert

jetro1971
10
jetro1971  

Hi again,

Let me start with the loop issue. The loop inside the OnTick() only works if new bar is formed, the other part works every time.

I'm using it on purpose because I want my technical indicators to decide the entry by looking hourly charts only, there is no need to run it all the time. Moreover, the Alert() function prints the values of the variables in the loop, since the loop works once every hour, i can trace it very well, otherwise, I'll be getting thousands of lines in journal without seeing what has happened.

My other functions such as trailing stop and risk functions to close the order works outside the loop in order to not to be late if a long bar comes against me.

void OnTick()

{

// ##### EVERY NEW BAR THE LOOP IS OPERATED ONCE ##

if (new_bar_time!= Time[0])

{ new_bar_time = Time[0];

// ----- Wildhog divergence indicator values ------------

double w0=iCustom(_Symbol,PERIOD_H1,FileName_Wildhog,0,1);

double w1=iCustom(_Symbol,PERIOD_H1,FileName_Wildhog,1,1);

double w2=iCustom(_Symbol,PERIOD_H1,FileName_Wildhog,2,1);

double w3=iCustom(_Symbol,PERIOD_H1,FileName_Wildhog,3,1);

double w4=iCustom(_Symbol,PERIOD_H1,FileName_Wildhog,4,1);

double w5=iCustom(_Symbol,PERIOD_H1,FileName_Wildhog,5,1);

// ----- Print values to Journal to check previous bar vales --------

Alert("Wildhog expert 0=",w0," 1=",w1," 2=",w2," 3=",w3," 4=",w4," 5=",w5);

} // new bar loop

}

[/CODE]

My aim is to get the index-1 of the wildhog indicator and print the variables of the indicator over expert. If you look at the indexbuffers in the indicator, they are:

[CODE]

IndicatorBuffers(6); SetIndexBuffer(0,Wildhog);

SetIndexBuffer(1,whda);

SetIndexBuffer(2,whdb);

SetIndexBuffer(3,bullishDivergence); SetIndexStyle(3,DRAW_ARROW,0,DivergearrowSize); SetIndexArrow(3,233);

SetIndexBuffer(4,bearishDivergence); SetIndexStyle(4,DRAW_ARROW,0,DivergearrowSize); SetIndexArrow(4,234);

SetIndexBuffer(5,slope);

The buffer-0 which is wildhog value of the indicator works fine. And I also tested that buffer-5 which is slope is working fine (previously I said there is issue, but now I see it's OK).

As I stated in the below picture, the buffer-3 (bullish divergence) and buffer-4 (bearish divergence) values never changes when I take these variables from the indicator. Normally I would expect that when there is a divergence the EMPTY_VALUE would become 1,-1 or 0 something that points that there is a divergence. Expert would never understand that there is a divergence.

The variables you add in your indicator is OK but they are not callable from expert by iCustom(). In order to call any variable from indicator it must be defined as indexbuffer (generally in Init() phase) and also they must be array.

This is where I'm squeezed since I'm not familiar with indicator coding, I only know how to call them from expert. I'm calling 4 different indicator in my expert successfully but could not managed this.

You can test what I'm saying if you run the expert in visual mode by inserting the wildhog indicator in the viusal mode chart, you will see that the indicator alerts/comments/arrows does not inline with what experts retrieves from the indicator. I guess it's related with indexbuffers but I really don't know how to fix it.

andreas73
831
andreas73  

Hello Guys,

I am wondering that there is no accumulation/distribution divergence with alert and arrows and so on indicator in here. Does anybody knows of one?

And does anyone knows of an divergence version indicator of FX Snipers T3 CCI? Thanks in advance

William Snyder
9491
William Snyder  
andreas73:
Hello Guys,

I am wondering that there is no accumulation/distribution divergence with alert and arrows and so on indicator in here. Does anybody knows of one?

And does anyone knows of an divergence version indicator of FX Snipers T3 CCI? Thanks in advance

Hello Andreas73,

For accumulation/distribution there is one here: https://www.forex-tsd.com/forum/debates-discussions/116-something-interesting-please-post-here/page560#comment_835802

William Snyder
9491
William Snyder  
andreas73:
Hello Guys,

I am wondering that there is no accumulation/distribution divergence with alert and arrows and so on indicator in here. Does anybody knows of one?

And does anyone knows of an divergence version indicator of FX Snipers T3 CCI? Thanks in advance

Andreas73, this is a T3 CCI with divergence, the T3 CCI is the same as the FX Snipers version, but with a few more options.

To add comments, please log in or register