Extend Target lines

B

Billy101

New member
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.

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:
H

horserider

Well-known member
VIP
Warehouse
Try adding something like this to the TQRTGTL

Code:
def countt = if IsNaN(TQRTGTL) and !IsNaN(TQRTGTL[1]) then 1 else countt[1] + 1;

plot tqrtgltext = if IsNaN(tqrtgtl) then GetValue(tQRTGTL, countt) else Double.NaN;

tqrtgltext.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

tqrtgltext.SetDefaultColor(Color.PINK);
Then repeat for TQRTGTH and of course you may not want pink as the color
 

Top