Hi Guys,
I've been working on a trend indicator similar to supertrend.
I'm having troubles to extend target lines over time until price crosses.
Please find attached an image of this indicator for your reference.
https://drive.google.com/open?id=1RPIaCwk--8c1pRDgEC74gc-jBldC4g9O
Thanks!
I've been working on a trend indicator similar to supertrend.
I'm having troubles to extend target lines over time until price crosses.
Please find attached an image of this indicator for your reference.
https://drive.google.com/open?id=1RPIaCwk--8c1pRDgEC74gc-jBldC4g9O
Thanks!
Code:
input lenghtCCI = 35;
input show = yes;
def tgt = 37;
def a = CCI(lenghtCCI)<-tgt;
def b = CCI(lenghtCCI)> tgt;
def state = if a>b then -1 else if a==b then 0 else 1;
AssignPriceColor ( if show == yes then if state == 0 then Color.GRAY else if state == 1 then Color.Blue else Color.RED else color.CURRENT);
def o = open;
def c = close;
def h = high;
def l = low;
def BarLngth = h - l;
def TQRH = h + (BarLngth/2);
def TQRL = l - (BarLngth/2);
def tqron=0;
def statechkh = if state[1]== 0 and state== 1 then TQRH else if state[1]== 0 and state== -1 then TQRH else double.nan ;
def statechkl = if state[1]== 0 and state== 1 then TQRL else if state[1]== 0 and state== -1 then TQRL else double.nan;
plot TQRTGTH = statechkh ;
TQRTGTH.SetPaintingStrategy(PaintingStrategy.Horizontal);
plot TQRTGTL = statechkl ;
TQRTGTL.SetPaintingStrategy(PaintingStrategy.Horizontal);
Last edited by a moderator: