HAS Indicator

 

As im not a programmer, I would appreciate some input.

I have tried to add arrows to the following indicator (HAS) so that a change in color of a closed bar is marked out on the chart. Based upon online tutorials, I took the original indicator and made some changes, I compiled it and it comes up with no errors or warning - but no arrows. If you could look at the code and tell me what is missing it would be appreciated. Thank you.

//+------------------------------------------------------------------+

//| 4TF HAS Bar.mq4 |

//+------------------------------------------------------------------+

#property indicator_chart_window

#property indicator_buffers 8

#property indicator_color1 Red

#property indicator_color2 Blue

#property indicator_color3 Red

#property indicator_color4 Blue

#property indicator_color5 Red

#property indicator_color6 Blue

#property indicator_color7 Red

#property indicator_color8 Blue

//---- parameters

extern int MaMetod = 2;

extern int MaPeriod = 6;

extern int MaMetod2 = 3;

extern int MaPeriod2 = 2;

extern int BarWidth = 0;

extern color BarColorUp = Blue;

extern color BarColorDown = Red;

extern color TextColor = White;

extern int MaxBars=500;

double Gap = 0; // Gap between the lines of bars

//---- buffers

double buf4_up[];

double buf4_down[];

double buf3_up[];

double buf3_down[];

double buf2_up[];

double buf2_down[];

double buf1_up[];

double buf1_down[];

double haOpen;

double haClose;

double haOpen2;

double haClose2;

string shortname = "";

int ArrSize = 110;//159;

int UniqueNum = 2282;

int Period_1, Period_2, Period_3, Period_4;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,234);

SetIndexBuffer(0,buf1_up);

SetIndexEmptyValue(0,0.0);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,233);

SetIndexBuffer(1,buf1_down);

SetIndexEmptyValue(1,0.0);

SetIndexStyle(2,DRAW_ARROW);

SetIndexArrow(2,234);

SetIndexBuffer(2,buf2_up);

SetIndexEmptyValue(2,0.0);

SetIndexStyle(3,DRAW_ARROW);

SetIndexArrow(3,233);

SetIndexBuffer(3,buf2_down);

SetIndexEmptyValue(3,0.0);

SetIndexStyle(4,DRAW_ARROW);

SetIndexArrow(4,234);

SetIndexBuffer(4,buf3_up);

SetIndexEmptyValue(4,0.0);

SetIndexStyle(5,DRAW_ARROW);

SetIndexArrow(5,233);

SetIndexBuffer(5,buf3_down);

SetIndexEmptyValue(5,0.0);

SetIndexStyle(6,DRAW_ARROW);

SetIndexArrow(6,234);

SetIndexBuffer(6,buf4_up);

SetIndexEmptyValue(6,0.0);

SetIndexStyle(7,DRAW_ARROW);

SetIndexArrow(7,233);

SetIndexBuffer(7,buf4_down);

SetIndexEmptyValue(7,0.0);

SetIndexLabel(0,NULL);

SetIndexLabel(1,NULL);

SetIndexLabel(2,NULL);

SetIndexLabel(3,NULL);

SetIndexLabel(4,NULL);

SetIndexLabel(5,NULL);

SetIndexLabel(6,NULL);

SetIndexLabel(7,NULL);

IndicatorDigits(0);

getPeriod();

shortname = "4TF-HAS ("+Period_1+","+Period_2+","+Period_3+","+Period_4+")";

IndicatorShortName(shortname);

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- the last counted bar will be recounted

if(counted_bars>0) counted_bars--;

int limit=Bars-counted_bars;

int i,tf;

//-------------------------------1----------------------------------------

double dif = Time[0] - Time[1];

for ( i=Bars-1; i>-1; i--)

{

if (StringFind(ObjectName(i),"FF_"+UniqueNum+"_") >= 0) ObjectDelete(ObjectName(i));

}

double shift = 0.2;

for ( tf=1; tf<=4; tf++)

{

string txt = "??";

double gp;

switch (tf)

{

case 1: txt = tf2txt(Period_1); gp = 1 + shift; break;

case 2: txt = tf2txt(Period_2); gp = 1 + Gap + shift; break;

case 3: txt = tf2txt(Period_3); gp = 1 + Gap*2 + shift; break;

case 4: txt = tf2txt(Period_4); gp = 1 + Gap*3 + shift; break;

}

string name = "FF_"+UniqueNum+"_"+tf+"_"+txt;

ObjectCreate(name, OBJ_TEXT, WindowFind(shortname), iTime(NULL,0,0)+dif*3, gp);

ObjectSetText(name, txt,8,"Arial", TextColor);

}

//-------------------------------2----------------------------------------

datetime TimeArray_4[], TimeArray_3[], TimeArray_2[], TimeArray_1[];

ArrayCopySeries(TimeArray_1,MODE_TIME,Symbol(),Period_1);

ArrayCopySeries(TimeArray_2,MODE_TIME,Symbol(),Period_2);

ArrayCopySeries(TimeArray_3,MODE_TIME,Symbol(),Period_3);

ArrayCopySeries(TimeArray_4,MODE_TIME,Symbol(),Period_4);

int i1=0, i2=0, i3=0, i4=0, yy;

// for(i=0, i1=0, i2=0, i3=0, i4=0;i<MaxBars;i++)

for(i=0, i1=0, i2=0, i3=0, i4=0;i<limit;i++)

{

if (Time<TimeArray_1) i1++;

if (Time<TimeArray_2) i2++;

if (Time<TimeArray_3) i3++;

if (Time<TimeArray_4) i4++;

for ( tf = 1; tf <= 4; tf++)

{

int prd;

switch (tf)

{

case 1: prd = Period_1; yy = i1; break;

case 2: prd = Period_2; yy = i2; break;

case 3: prd = Period_3; yy = i3; break;

case 4: prd = Period_4; yy = i4; break;

}

haOpen = iCustom(NULL,prd,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,yy) ;

haClose = iCustom(NULL,prd,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,yy) ;

switch (tf)

{ case 1: buf1_down=EMPTY_VALUE;buf1_up=EMPTY_VALUE; if (haOpen>=haClose) buf1_down = 1; else buf1_up = 1; break;

case 2: buf2_down=EMPTY_VALUE;buf2_up=EMPTY_VALUE; if (haOpen>=haClose) buf2_down = 1 + Gap * 1; else buf2_up = 1 + Gap * 1; break;

case 3: buf3_down=EMPTY_VALUE;buf3_up=EMPTY_VALUE; if (haOpen>=haClose) buf3_down = 1 + Gap * 2; else buf3_up = 1 + Gap * 2; break;

case 4: buf4_down=EMPTY_VALUE;buf4_up=EMPTY_VALUE; if (haOpen>=haClose) buf4_down = 1 + Gap * 3; else buf4_up = 1 + Gap * 3; break;

}

}

}

return(0);

}

//+------------------------------------------------------------------+

void getPeriod()

{

switch(Period())

{

case 1:

Period_1=1; Period_2=5; Period_3=15; Period_4=30;

break;

case 5:

Period_1=5; Period_2=15; Period_3=30; Period_4=60;

break;

case 15:

Period_1=15; Period_2=30; Period_3=60; Period_4=240;

break;

case 30:

Period_1=30; Period_2=60; Period_3=240; Period_4=1440;

break;

case 60:

Period_1=60; Period_2=240; Period_3=1440; Period_4=10080;

break;

case 240:

Period_1=240; Period_2=1440; Period_3=10080; Period_4=43200;

break;

case 1440:

Period_1=1440; Period_2=10080; Period_3=43200; Period_4=43200;

break;

case 10080:

Period_1=10080; Period_2=43200; Period_3=43200; Period_4=43200;

break;

case 43200:

Period_1=43200; Period_2=43200; Period_3=43200; Period_4=43200;

break;

}

}

string tf2txt(int tf)

{

if (tf == PERIOD_M1) return("M1");

if (tf == PERIOD_M5) return("M5");

if (tf == PERIOD_M15) return("M15");

if (tf == PERIOD_M30) return("M30");

if (tf == PERIOD_H1) return("H1");

if (tf == PERIOD_H4) return("H4");

if (tf == PERIOD_D1) return("D1");

if (tf == PERIOD_W1) return("W1");

if (tf == PERIOD_MN1) return("MN");

return("??");

}

/*bool NewBar()

{

static datetime dt = 0;

if (Time[0] != dt)

{

dt = Time[0];

return(true);

}

return(false);

}

*/

 

Has

Has..........:

Files:
has.mq4  7 kb
 

Still no arrows......

Do you need to create an entirely new indicator? I started with metaeditor and created a new custom indicator, added the arrows and pasted the HAS indicator code under the Custom indicator iteration function, what else would I need to add to get the arrows on screen?

 
 

A Baby Trader.........

what the concept of the indicator.....when generate it generate signal?

an ebook could help me.......

 

is HAS Heikin Ashi?

I made 2 indicators to alert for Heikin Ashi DM change of colour

Files:
 
camisa:
is HAS Heikin Ashi? I made 2 indicators to alert for Heikin Ashi DM change of colour

Muito obrigado Camisa.

Thank you!

 

A Baby Trader.........

heartnet:
what the concept of the indicator.....when generate it generate signal? an ebook could help me.......

someone...Im a newbie......a pdf about HAS system.....is it some kind that work like;top trend and parabolic sar

 

we tried similar thing with xo - multi-mtf signals - Very hard and inconvenient to trade - especially combined in one:

- while tf0 - 1 bar, higher tf - (60min - 12 of 5 min bars) - and it's open - signal changes - whole 12 bars wide floor shifts and moves as it's goes, arrows appear and disappear - drives codetrs/testers crasy - (traders go nuts) - visual perception gets too complicated, to confusing and misleading 4 interpretation (even for mtf fans) -

so we tryed it back and force with different ways and approaches - and we didn't liked it

our experuience - the best visual - still - bar type(has) or histo(xo) as is...

(p.s. if you heard people accusing all mtfs in repainting- - wait untill you addsignals (on chart or sw)- consider you didn't heard nothing yet..." : - ))))

 
heartnet:
what the concept of the indicator.....when generate it generate signal? an ebook could help me.......

There are five primary signals that identify trends and buying opportunities:

- Hollow candles with no lower "shadows" indicate a strong uptrend: let your profits ride!

- Hollow candles signify an uptrend: you might want to add to your long position, and exit short positions.

- One candle with a small body surrounded by upper and lower shadows indicates a trend change: risk-loving traders might buy or sell here, while others will wait for confirmation before going short or long.

- Filled candles indicate a downtrend: you might want to add to your short position, and exit long positions.

- Filled candles with no higher shadows identify a strong downtrend: stay short until there's a change in trend.

These signals show that locating trends or opportunities becomes a lot easier with this system. The trends are not interrupted by false signals as often, and are thus more easily spotted. Furthermore, opportunities to buy during times of consolidation are also apparent

Reason: