HA SMOOTHED with Indicator (up/down arrows)

sunnybabu

New member
VIP
Folks,

I'm trying to offset the buy/sell indicators, so that we can avoid short-term buy/sell signals for the Smoothed HA chart? Clearly I'm lack of thoughst here.. any advice is greatly appreciated. @BonBon , Maa'm you seem to be expert in this, any advice on this is greatly is appreciated. Many thanks

wanted to avoid these false positives by some offset and avoid REPAINTING?

cjGLsuo.jpg
3uKZUvj.jpg


Code:
input show_smoothed_candles_only = yes;
hidepricePlot(show_smoothed_candles_only);
input candleSmoothing = {default HACO, HACO_Mod};

input avg = averageType.EXPONENTIAL;
input len = 8;#=input(10)
def o = movingAverage(avg,open, len);
def c = movingAverage(avg,close, len);
def h = movingAverage(avg,high, len);
def l = movingAverage(avg,low, len);

def HAopen;
def HAclose;


switch(candleSmoothing) {
 
case HACO:
    haOpen = CompoundValue(1, ( (haOpen[1] + (o[1] + h[1] + l[1] + c[1]) /4)/2), open);
    haClose = ((((O + H + L + C)/4) + haOpen + Max(H, haOpen) + Min(L, haOpen))/4);

case HACO_Mod:

    haOpen = CompoundValue(1, ( (haOpen[1] + (o[1] + h[1] + l[1] + c[1]) /4)/2), open);
    haClose = ((o + h + l + c)/4) ;
}
def HAhigh    = Max( h, Max( HAopen, HAclose ) );
def HAlow     = Min( l, Min( HAopen, HAclose ) );

#def diff = haclose - haopen; #rj added

input len2 = 17;#input(10)
def o2 = movingAverage(avg,HAopen, len2);
def c2 = movingAverage(avg,HAclose, len2);
def h2 = movingAverage(avg,HAhigh, len2);
def l2 = movingAverage(avg,HAlow, len2);

input charttype=chartType.CANDLE;
def o3 = o2;
def h3 = h2;
def l3 = l2;
def c3 = c2;

input nowicks = yes;


def o4 = if o3<c3 then if nowicks then l3 else o3 else double.nan;
def c4 = if o3<c3 then if nowicks then h3 else c3 else double.nan;
def h4 = if o3<c3 then h3 else double.nan;
def l4 = if o3<c3 then l3 else double.nan;

AddChart(growColor = color.green, fallColor = color.red, neutralColor = color.current, high = h4, low = l4, open = c4, close = o4, type = chartType.CANDLE);


def o5 = if o3 >=c3 then if nowicks then h3 else o3 else double.nan;
def h5 = h3;
def l5 = l3;
def c5 = if o3 >=c3 then if nowicks then l3 else  c3 else double.nan;
AddChart(growColor = color.red, fallColor = color.green, neutralColor = color.CURRENT, high = h5, low = l5, open = o5, close = c5, type = chartType);

plot ArrowUp = if c > c2 and isNaN(c5) and !isNaN(c5[1])
               then l5
               else double.nan;
     ArrowUp.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
plot ArrowDn = if c < c2 and isNaN(c5[1]) and !isNaN(c5)
               then h5
               else double.nan;
     ArrowDn.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
 
Last edited:

Similar threads

Top