N4 TF Has Bar Coding ?

 

First off, I would like to thank all the coders on this form for all their great work! Your teachings are invaluable!

Got a question for a coder. Im new to codeing and dont understand iCustom that much yet but her it goes. I get lost when the indicator is not returning a number value and returns an arrow with a color. I would like to use the N4 TF Has Bar custom indicator in my code and know how to use the arrow or color of the returned value but I am having a pore understanding of what this indicator is giving as its value. I think I got the syntax of the indicator of :

iCustom(NULL,0,"N4 TF Has Bar",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,BarColorUp,BarColorDown,TextColor,MaxBars,HasBarPeriod,1);

What value does this code return? I would like to use this code for a color or arrow change of a bar on a time like:

HasColor=iCustom(NULL,0,"N4 TF Has Bar",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,BarColorUp,BarColorDown,TextColor,MaxBars,HasBarPeriod,1);

or

HasArrow=iCustom(NULL,0,"N4 TF Has Bar",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,BarColorUp,BarColorDown,TextColor,MaxBars,HasBarPeriod,1);

if(HasColor==Blue)

or

if(HasArrow==up)

Hascolor = color of previous bar of the 3rd highest time frame on the indicator and "HasBarPeriod" = one of the 4 time frames on the indicator.

HasArrow = up of previous bar of the 3rd highest time frame on the indicator and "HasBarPeriod" = one of the 4 time frames on the indicator.

So if the previous arrow is up (Blue) on the 3rd highest time frame of the indicator it would buy but I would like to enter the trade on the color or arrow change of the indicator.

PS: Coders guru Thank you so much for all your lessons on MQL4.

 
 
mikeschra:

iCustom(NULL,0,"N4 TF Has Bar",MaMetod,MaPeriod,MaMetod2,MaPeriod2,BarWidth,BarColorUp,BarColorDown,TextColor,MaxBars,HasBarPeriod,1);

What value does this code return?

The iCustom(..) function returns the value of an entry in a buffer of the indicator. The last two arguments tell buffer number and index into that buffer.

So it is: iCustom(..., BufferNumber, Index )

You have to refer to the indicator code to know which buffer to read off. Usually you can see this by opening the Data Window (with the indicator attached), and then count from 0. I.e., buffer number 0 refers to the first

indicator buffer, 1 to the second etc.

Then you tell which Indexm i.e. for which bar into the past to get the value. Index 0 is the currently building bar, Index 1 the most recently completed bar, etc.

 

Yep, Thats right....but as i mentioned at the end of my last post i have not concluded the hole post yet. Have wife issues at the moment!

 
 
mikeschra:
Yep, Thats right....but as i mentioned at the end of my last post i have not concluded the hole post yet. Have wife issues at the moment!

Sorry about that. Am I too simple to recognize a rhetorical question?

 

LOL....Not a problem, just hope I have the time to finish my example tonight.

 
 

EA not trading right

Well I wrote a simple ea that does not work. Any ideas from anyone why it does not follow the rules.

The Rules: On a M5 Chart when the second line from the bottom of the N4 TF HAS Bar (M15 Line) Changes from blue to red go short & when it changes from red to blue to go long. This is not on the current bar of the chart but one bar back as to avoid the current bar from changing from blue to red then back to blue. As you can see in my examples its not following these rules at all, not even close and since im not a coder I have no clue why. Any assistance would be great!

n4_tf_has_bar_example_ea.mq4

Files:
 

Ea

In reply to a pm.

Here is the modified EA that should work correctly. Do not know if it will make profit but it will read the HAS correctly for trade direction.

Please note that when using the value from the 15 minute chart on the 5 minute chart the colors for 3 bars are for the corresponding open candle on the 15 minute chart. The EA is coded to only look at the current chart timeframe. So it does not follow your rules exactly as stated.

Robert

 

Thanks.Let me try.

Is this an attempt to create Steinitz EA Clone?

Reason: