Newbie needs help getting EA to recognize a bar color

 

Greetings!

I am a newbie that is familiar with programming EAs, but I do not understand the custom indicators very well. I need some help getting my EA to recognize an indicator's bar color

I am using the Heiken_Ashi_Smoothed indicator (attached and modified for my use). I would like my EA to look one period back (shift == 1) and determine the COLOR that was used on that bar. If I can get the EA to determine the color that was used to draw the bar, then I can write the code for the appropriate action.

For example:

If PreviousBarColor == Red, then call function A; if PreviousBarColor == RoyalBlue, then call function B.

Help would be greatly appreciated as I have found a consistent pattern to accumulate pips quickly. Thank you.

Files:
 

Do an iCustom() call to the indicator.

index 2 and 3 define the body.

if index2 > index3 then the color is blue. if index2 < index3 the color is red.

I might have the blue/red backwards.

You can figure out which is which by testing.

 
phy wrote >>

Do an iCustom() call to the indicator.

index 2 and 3 define the body.

if index2 > index3 then the color is blue. if index2 < index3 the color is red.

I might have the blue/red backwards.

You can figure out which is which by testing.

Phy;

Thank you for the advice. I will program the EA later tonight and follow up with the resuts.

Daniel

 
daniel295261 wrote >>

Phy;

Thank you for the advice. I will program the EA later tonight and follow up with the resuts.

Daniel

Daniel, Phy,

sorry I'm a newbie;-)

I would like to write a code that recognise when an AC bar is green or red.

I tried as follow ...but it does not work

/+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
string AC_color_bar;
int val;
int cnt, ticket, total;
int Ac_color, index1, index2;
val=iCustom(NULL,0,"AC",0,2,0);
//index2=iCustom(NULL,0,"AC",0,1,0);
index1=indicator_buffers(2)
index2=indicator_buffers(3)
string sComment;
sComment="";
sComment=sComment+"Index1="+index1+"\n";
sComment=sComment+"Index2="+index2+"\n";
Comment(sComment);

return(0);

Can you help me ?

 

Read up on iCustom

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 2, 1) ; // gets index2 of bar 1

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 3, 1) ; // gets index3 of bar 1

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 2, 2) ; // gets index2 of bar 2

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 3, 2) ; // gets index3 of bar 2

The color of the body is decided by the relationship of index 2 and 3.

 
phy wrote >>

Read up on iCustom

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 2, 1) ; // gets index2 of bar 1

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 3, 1) ; // gets index3 of bar 1

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 2, 2) ; // gets index2 of bar 2

iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 3, 2) ; // gets index3 of bar 2

The color of the body is decided by the relationship of index 2 and 3.

Hi Phy

thanks a lot for your help ;-)

But, I asked for Bill Williams' Accelerator/Decelerator (the AC indicator ) i.s.o Heiken Ashi Smoothed ;-)

Moreover is not clear if, to get index2 and index I should write a code like:

int index2;

int index3;

index2=iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 2, 1) ; // gets index2 of bar 1

index3=iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 3, 1) ; // gets index3 of bar 1

If (index2<index3)

............

Can you help me please

Thanks in advance

Fabio

 
daniel295261 wrote >>

Phy;

Thank you for the advice. I will program the EA later tonight and follow up with the resuts.

Daniel

Hello again Phy;

Just wanted to report that I did indeed program the EA using your information and it is working like a charm! I see that this is a common question with the HA indicator and I appreciate you taking the time to . . . repeat yourself with this one. Unfortuneately the documentation is not very clear on how to set this particular indicator using iCustom. But I did learn from your example and have also been able to apply what you showed me to other situations.

Thanks again for all your help!!

 
Creating bars on the main chart is a special function of Indicators histogram, and is not very well explained.
 
phy wrote >>
Creating bars on the main chart is a special function of Indicators histogram, and is not very well explained.

Hi Phy

thanks a lot for your help ;-)

But, I asked for Bill Williams' Accelerator/Decelerator (the AC indicator ) i.s.o Heiken Ashi Smoothed ;-)

Moreover is not clear if, to get index2 and index I should write a code like:

int index2;

int index3;

index2=iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 2, 1) ; // gets index2 of bar 1

index3=iCustom(Symbol(), 0, "Heiken Ashi Smoothed", 2, 6, 3, 2, 3, 1) ; // gets index3 of bar 1

If (index2<index3)

............

Can you help me please

Thanks in advance

Fabio

 
phy:
Creating bars on the main chart is a special function of Indicators histogram, and is not very well explained.

Hi phy,I have seen that you are good in programming and this Ea could be usefull for both of us. I want to ask you,if you can help me with tweaking this EA. It is based on Heiken ashi smoothed indicator. My problem is that this Ea opens trades imediately, when it can and i want to change this. Do you think you can tweak this Ea that way, it will open trades only on the change of color? For example: it has a blue color,it will open buy position. When i close the position on TP or SL, it will wait for the colour change. I see a big potential in this Ea,but this tweak is needed for it to be fully functional. And also add this values: - on which tick after the trade is opened will EA close the trade.


Thanks

Miro :)

 
phy wrote >>
Creating bars on the main chart is a special function of Indicators histogram, and is not very well explained.

Phy,

I see your forum name a lot. You seem very good with programing. I have a question on a program ensign uses that is very simple but effective, its called a predictive average. a fellow trader and I have set its functions in ensign to perfection but I have no clue how to set it up for metatrader. Could you email me at ah@embarqmail.com and I could forward a picture plus ensign setting to see if this could be duplicated in meta?

Thanks in advance

Al

Reason: