henry1224's TASC Pos Neg Indicator with Extras

This is the place to discuss EdgeRater Chart Script

Moderator: Chris White

Post Reply
bsegura
Posts: 32
Joined: Tue Jan 12, 2021 11:56 am

henry1224's TASC Pos Neg Indicator with Extras

Post by bsegura »

With respect to henry1224, I added a few extra features to his uploaded Indicator. I hope he finds the additions useful.
1. I added a Hull 55 Period Moving Average
2. I added the ClimaxUP (Green) and ClimaxDown (red) elements from the Better Volume Indicator
3. I have then highest close and lowest close for both 10 and 20 periods

Regards,
Brian


Code: Select all

//Original code by henry1224

Apr:= (High + Low + Close)/3;
At:=ATR(pds)*0.1;
Vpd:= If (APR >= (Ref(APR,1) + at),Volume,0);
VNd:= If (APR <= (Ref(APR,1) - at),Volume,0);
VP:= Sum(VPD,Pds);
VN:= Sum(VND,Pds);
VPN: (((VP-VN)/MA(Volume,Pds))/Pds)*100,Width2,Color.Blue;
VPNA: EMA(VPN,APDS),Width2,Color.Red;
MMax:= Max(VPN,VPNA);
MMin:= Min(VPN,VPNA);
FillRGN(MMin > 0,MMin,0),Brush#200000FF;
FillRGN(MMax < 0,MMax,0),Brush#30FF7F50;
FILLRGN(VPN>VPNA,VPN,VPNA),Brush#600000FF;
FILLRGN(VPNA>VPN,VPNA,VPN),Brush#50FF0000;
//UpperZone: MA(VPN,34)+(1.3185*Std(VPN,34)),Width1,ColorBlack;
//LowerZone: MA(VPN,34)-(1.3185*Std(VPN,34)),Width1,ColorBlack;


// Additional code added by bsegura

hullma(vpn,55),width2;

// Better Volume Indicator

range := abs(high - low);
 
x1 := close>open & range != 0;
x2 := (range/(2*Range+Open-Close)) * V;

x3 := close<open & range !=0;
x4 := ((range+close-open)/(2*Range+close-open)) * V;

x5 := close==open;
x6 := 0.5 * V;

value1 := if(x1,x2,if(x3,x4,if(x5,x6,nan)));
value2 := v - value1;

value3 := abs(value1 + value2);
value4 := value1 * range;
value5 := (value1-value2)*range;
value6 := value2*range;
value7 := (value2-value1)*range;

value8  := if(range != 0,value1/range,nan);
value9  := if(range != 0,(value1-value2)/range,nan);
value10 := if(range != 0,value2/range,nan);
value11 := if(range != 0,(value2-value1)/range,nan);
value12 := if(range != 0, value3/range,nan);

use2bars := 0;

value13 := if (use2bars,value3-value3[1],nan);
value14 := if (use2bars,(value1+value1[1])*(hhv(h,2)-llv(l,2)),nan);
value15 := if (use2bars,(value1+value1[1]-value2-value2[1])*(hhv(h,2)-llv(l,2)),nan);
value16 := if (use2bars,(value2+value2[1])*(hhv(h,2)-llv(l,2)),nan);
value17 := if (use2bars,(value2+value2[1]-value1-value1[1])*(hhv(h,2)-llv(l,2)),nan);
value18 := if (use2bars,(value1+value1[1]-value2-value2[1])/(hhv(h,2)-llv(l,2)),nan);
value19 := if (use2bars,(value1+value1[1]-value2-value2[1])/(hhv(h,2)-llv(l,2)),nan);
value20 := if (use2bars,(value2+value2[1])/(hhv(h,2)-llv(l,2)),nan);
value21 := if (use2bars,(value2+value2[1]-value1-value1[1])/(hhv(h,2)-llv(l,2)),nan);
value22 := if (use2bars,value13/(hhv(h,2)-llv(l,2)),nan);

lookback := 20;

cond1  := value3 == llv(value3, lookback);
cond2  := value4 == hhv(value4, lookback) & c>o;
cond3  := value5 == hhv(value5, lookback) & c>o;
cond4  := value6 == hhv(value6, lookback) & c<o;
cond5  := value7 == hhv(value7, lookback) & c<o;
cond6  := value8 == llv(value8, lookback) & c<o;
cond7  := value9 == llv(value9, lookback) & c<o;
cond8  := value10 == llv(value10,lookback) & c>o;
cond9  := value11 == llv(value11,lookback) & c>o;
cond10 := value12 == hhv(value12,lookback);

 
cond11 := use2bars==1 & value13 == llv(value13,lookback);
cond12 := use2bars==1 & value14 == hhv(value14,lookback) & c>o & ref(c,1) > ref(o,1);
cond13 := use2bars==1 & value15 == hhv(value15,lookback) & c>o & ref(c,1) > ref(o,1);
cond14 := use2bars==1 & value16 == hhv(value16,lookback) & c<o & ref(c,1) < ref(o,1);
cond15 := use2bars==1 & value17 == hhv(value17,lookback) & c<o & ref(c,1) < ref(o,1);
cond16 := use2bars==1 & value18 == llv(value18,lookback) & c<o & ref(c,1) < ref(o,1);
cond17 := use2bars==1 & value19 == llv(value19,lookback) & c<o & ref(c,1) < ref(o,1);
cond18 := use2bars==1 & value20 == llv(value20,lookback) & c>o & ref(c,1) > ref(o,1);
cond19 := use2bars==1 & value21 == llv(value21,lookback) & c>o & ref(c,1) > ref(o,1);
cond20 := use2bars==1 & value22 == hhv(value22,lookback);
 
Lookback_weak := 10;

cond1w  := value3 == llv(value3,  lookback_weak);
cond2w  := value4 == hhv(value4,  lookback_weak) & c>o;
cond3w  := value5 == hhv(value5,  lookback_weak) & c>o;
cond4w  := value6 == hhv(value6,  lookback_weak) & c<o;
cond5w  := value7 == hhv(value7,  lookback_weak) & c<o;
cond6w  := value8 == llv(value8,  lookback_weak) & c<o;
cond7w  := value9 == llv(value9,  lookback_weak) & c<o;
cond8w  := value10 == llv(value10,lookback_weak) & c>o;
cond9w  := value11 == llv(value11,lookback_weak) & c>o;
cond10w := value12 == hhv(value12,lookback_weak);

cond11w := use2bars==1 & value13 == llv(value13,lookback_weak);
cond12w := use2bars==1 & value14 == hhv(value14,lookback_weak) & c>o & ref(c,1) > ref(o,1);
cond13w := use2bars==1 & value15 == hhv(value15,lookback_weak) & c>o & ref(c,1) > ref(o,1);
cond14w := use2bars==1 & value16 == hhv(value16,lookback_weak) & c<o & ref(c,1) < ref(o,1);
cond15w := use2bars==1 & value17 == hhv(value17,lookback_weak) & c<o & ref(c,1) < ref(o,1);
cond16w := use2bars==1 & value18 == llv(value18,lookback_weak) & c<o & ref(c,1) < ref(o,1);
cond17w := use2bars==1 & value19 == llv(value19,lookback_weak) & c<o & ref(c,1) < ref(o,1);
cond18w := use2bars==1 & value20 == llv(value20,lookback_weak) & c>o & ref(c,1) > ref(o,1);
cond19w := use2bars==1 & value21 == llv(value21,lookback_weak) & c>o & ref(c,1) > ref(o,1);
cond20w := use2bars==1 & value22 == hhv(value22,lookback_weak);
 

LowVol      := (cond1 | cond11);
ClimaxUp    := (cond2 | cond3 | cond8 | cond9 | cond12 | cond13 | cond18 | cond19);
ClimaxDown  := (cond4 | cond5 | cond6 | cond7 | cond14 | cond15 | cond16 | cond17);
Churn       := (cond10 | cond20);
ClimaxChurn := (cond10 | cond20) & (cond2 | cond3 | cond4 | cond5 | cond6 | cond7 | cond8 | cond9 | cond12 | cond13 | cond14 | cond15 | cond16 | cond17 | cond18 | cond19);

LowVol_w      := (cond1w | cond11w);
ClimaxUp_w    := (cond2w | cond3w | cond8w | cond9w | cond12w | cond13w | cond18w | cond19w);
ClimaxDown_w  := (cond4w | cond5w | cond6w | cond7w | cond14w | cond15w | cond16w | cond17w);
Churn_w       := (cond10w | cond20w);
ClimaxChurn_w := (cond10w | cond20w) & (cond2w | cond3w | cond4w | cond5w | cond6w | cond7w | cond8w | cond9w | cond12w | cond13w | cond14w | cond15w | cond16w | cond17w | cond18w | cond19w);

value3a := value3/1000000;
//value3,colorstick,colorgreen;
//DRAWSHAPE(LowVol,  value3 *.1,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.2,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.3,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.4,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.5,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.6,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.7,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.8,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 *.9,1,true,0,'square',.75,'yellow', 'yellow');
//DRAWSHAPE(LowVol,  value3 * 1,1,true,0,'square',.75,'yellow', 'yellow');

DRAWSHAPE(ClimaxUp,   value3a *.05,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.10,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.15,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.20,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.25,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.30,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.35,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.40,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.45,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.50,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.55,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.60,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.65,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.70,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.75,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.80,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.85,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.90,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a *.95,1,true,0,'square',.75,'red',    'red');
DRAWSHAPE(ClimaxUp,   value3a * 1 ,1,true,0,'square',.75,'red',    'red');

DRAWSHAPE(ClimaxDown, value3a *.05,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.10,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.15,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.20,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.25,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.30,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.35,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.40,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.45,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.50,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.55,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.60,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.65,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.70,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.75,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.80,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.85,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.90,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a *.95,1,true,0,'square',.75,'orange', 'orange');
DRAWSHAPE(ClimaxDown, value3a * 1 ,1,true,0,'square',.75,'orange', 'orange');

//DRAWSHAPE(Churn,      value3 * .05,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .10,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .15,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .20,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .25,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .30,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .35,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .40,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .45,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .50,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .55,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .60,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .65,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .70,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .75,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .80,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .85,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .90,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 * .95,1,true,0,'square',.75,'limegreen',  'limegreen');
//DRAWSHAPE(Churn,      value3 *  1 ,1,true,0,'square',.75,'limegreen',  'limegreen');

//DRAWSHAPE(ClimaxChurn,value3 *.05,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.10,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.15,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.20,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.25,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.30,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.35,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.40,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.45,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.50,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.55,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.60,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.65,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.70,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.75,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.80,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.85,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.90,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.95,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 * 1 ,1,true,0,'square',.75,'magenta','magenta');
//DRAWSHAPE(ClimaxChurn,value3 *.05,1,true,0,'square',.75,'magenta','magenta');


d1 : if(close>ref(close,1) & close>ref(close,2) & close>ref(close,3) & close>ref(close,4) & close>ref(close,5) & close>ref(close,6) & close>ref(close,7) & close>ref(close,8) & close>ref(close,9) & close>ref(close,10),33,31),colorblack,width2;
d2 : if(close>ref(close,1) & close>ref(close,2) & close>ref(close,3) & close>ref(close,4) & close>ref(close,5) & close>ref(close,6) & close>ref(close,7) & close>ref(close,8) & close>ref(close,9) & close>ref(close,10) & close>ref(close,11) & close>ref(close,12) & close>ref(close,13) & close>ref(close,14) & close>ref(close,15) & close>ref(close,16) & close>ref(close,17) & close>ref(close,18) & close>ref(close,19) & close>ref(close,20),38,36),colorblack,width2;
 

d3 : if(close<ref(close,1) & close<ref(close,2) & close<ref(close,3) & close<ref(close,4) & close<ref(close,5) & close<ref(close,6) & close<ref(close,7) & close<ref(close,8) & close<ref(close,9) & close<ref(close,10),-33,-31),colorblack,width2;
d4 : if(close<ref(close,1) & close<ref(close,2) & close<ref(close,3) & close<ref(close,4) & close<ref(close,5) & close<ref(close,6) & close<ref(close,7) & close<ref(close,8) & close<ref(close,9) & close<ref(close,10) & close<ref(close,11) & close<ref(close,12) & close<ref(close,13) & close<ref(close,14) & close<ref(close,15) & close<ref(close,16) & close<ref(close,17) & close<ref(close,18) & close<ref(close,19) & close<ref(close,20),-38,-36),colorblack,width2;
Post Reply