예스스탁
예스스탁 답변
2024-08-19 18:09:29
안녕하세요
예스스탁입니다.
1
input : signal(3);
input : long(27);
input : vmacd(true);
input : vinv(false);
input : norm(false);
var : vol(0),tr(0),BBP(0),SSP(0);
var : TP(0),BPV(0),SPV(0),TPV(0),BPVavg(0),SPVavg(0),TPVavg(0);
var : VN(0),BPN(0),SPN(0),TPN(0);
var : nbf(0),nsf(0),tpf(0),ndif(0);
var : BPc1(0),BPc2(0),SPc1(0),SPc2(0);
var : BPcon(0),SPcon(0),BPAcon(0),SPAcon(0),TPAcon(0);
var : vpo1(0),vpo2(0),vph(0),histC(0),Vpo1C(0),Vpo2C(0);
vol = iff(volume > 0, volume , 1);
// Bull And Bear "Power-Balance" by Vadim Gimelfarb Algorithm's
BBP = iff(close<open, iff(close[1]<open, max(high-close[1], close-low),
max(high-open, close-low)),
iff(close>open, iff(close[1]>open, high-low,
max(open-close[1], high-low)),
iff(high-close>close-low, iff(close[1]<open, max(high-close[1],close-low),
high-open),
iff(high-close<close-low, iff(close[1]>open, high-low,
max(open-close[1], high-low)),
iff(close[1]>open, max(high-open, close-low),
iff(close[1]<open, max(open-close[1], high-low),
high-low))))));
SSP = iff(close<open, iff(close[1]>open, max(close[1]-open, high-low),
high-low),
iff(close>open, iff(close[1]>open, max(close[1]-low, high-close),
max(open-low, high-close)),
iff(high-close>close-low, iff(close[1]>open, max(close[1]-open, high-low),
high-low),
iff(high-close<close-low, iff(close[1]>open, max(close[1]-low, high-close),
open-low),
iff(close[1]>open, max(close[1]-open, high-low),
iff(close[1]<open, max(open-low, high-close),
high-low))))));
TP = BBP+SSP;
// RAW Pressure Volume Calculations
BPV = (BBP/TP)*vol;
SPV = (SSP/TP)*vol;
TPV = BPV+SPV;
BPVavg = ema(ema(BPV,signal),signal);
SPVavg = ema(ema(SPV,signal),signal);
TPVavg = ema(wma(TPV,signal),signal);
VN = vol/ema(vol,long);
BPN = ((BBP/ema(BBP,long))*VN)*100;
SPN = ((SSP/ema(SSP,long))*VN)*100;
TPN = BPN+SPN;
nbf = ema(wma(BPN,signal),signal);
nsf = ema(wma(SPN,signal),signal);
tpf = ema(wma(TPN,signal),signal);
ndif = nbf-nsf;
BPc1 = iff(BPV>SPV , BPV , -abs(BPV));
BPc2 = iff(BPN>SPN , BPN , -abs(BPN));
SPc1 = iff(SPV>BPV , SPV , -abs(SPV));
SPc2 = iff(SPN>BPN , SPN , -abs(SPN));
BPcon = iff(norm , BPc2 , BPc1);
SPcon = iff(norm , SPc2 , SPc1);
BPAcon = iff(norm , nbf , BPVavg);
SPAcon = iff(norm , nsf , SPVavg);
TPAcon = iff(norm , tpf , TPVavg);
vpo1 = iff(vinv , (( AccumN(BPVavg,long)-AccumN(SPVavg,long))/AccumN(TPVavg,long))*100 , ((BPVavg-SPVavg)/TPVavg)*100);
vpo2 = iff(vinv , (( AccumN(nbf,long)-AccumN(nsf,long))/AccumN(tpf,long))*100 , ((nbf-nsf)/tpf)*100);
vph = iff(IsNan(vpo1 - vpo2)==true,0,vpo1 - vpo2);
// Plot Indicator
histC = iff(vph > vph[1] , blue,Red);
Vpo1C = iff(vpo1 > 0 , green,red);
Vpo2C = iff(vpo2 > 0 , green,red);
plot1(iff(vmacd , nan,SPcon),"SELLING", red);
plot2(iff(vmacd , nan,BPcon),"BUYING", green);
plot3(iff(vmacd , nan,SPAcon),"SPAvg", red);
plot4(iff(vmacd , nan,BPAcon),"BPAvg", green);
plot5(iff(vmacd , vpo1,nan),"VPO1", Vpo1C);
plot6(iff(vmacd , vpo2,nan),"VPO2", Vpo2C);
plot7(iff(vmacd , vph,nan),"VPH", histC);
2
input : Factor(3);
input : Pd(80);
var : hl2(0),up(0),dn(0);
var : TrendUp(0),TrendDown(0),Trend(0),Tsl(0),linecolor(0);
hl2 = (h+l)/2;
Up=hl2-(Factor*atr(Pd));
Dn=hl2+(Factor*atr(Pd));
TrendUp=iff(close[1]>TrendUp[1] , max(Up,TrendUp[1]) , Up);
TrendDown=iff(close[1]<TrendDown[1] , min(Dn,TrendDown[1]) , Dn);
Trend = iff(close > TrendDown[1] , 1 , IFf( close< TrendUp[1] , -1 , iff(IsNan(Trend[1])==true,1,Trend[1])));
Tsl = iff(Trend==1 , TrendUp , TrendDown);
linecolor = iff(Trend == 1 , green , red);
plot1(Tsl, "SuperTrend",linecolor);
즐거운 하루되세요
> bw 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 트레이딩뷰 지표인데 변환 부탁드립니다.
2가지 지표입니다.
1번째 지표 : BUY & SELL VOLUME TO PRICE PRESSURE
signal = input(title="Base for FastMA Periods:", type=integer, defval=3)
long = input(title="Buy to Sell Conv/Div Lookback:", type=integer, defval=27)
vmacd = input(true, title="Buy to Sell Convergence/Div OSC:")
vinv = input(false, title="Buy to Sell Conv/Div as cummulative:")
norm = input(false, title="Normalised (Filtered) Version:")
//vapi = input(false, title="Display Acc/Dist % :")
vol = iff(volume > 0, volume , 1)
// PRESSURE ALGORITHMS AND VARIABLES
TR = atr(1)
// Bull And Bear "Power-Balance" by Vadim Gimelfarb Algorithm's
BP = iff(close<open, iff(close[1]<open, max(high-close[1], close-low),
max(high-open, close-low)),
iff(close>open, iff(close[1]>open, high-low,
max(open-close[1], high-low)),
iff(high-close>close-low, iff(close[1]<open, max(high-close[1],close-low),
high-open),
iff(high-close<close-low, iff(close[1]>open, high-low,
max(open-close[1], high-low)),
iff(close[1]>open, max(high-open, close-low),
iff(close[1]<open, max(open-close[1], high-low),
high-low))))))
SP = iff(close<open, iff(close[1]>open, max(close[1]-open, high-low),
high-low),
iff(close>open, iff(close[1]>open, max(close[1]-low, high-close),
max(open-low, high-close)),
iff(high-close>close-low, iff(close[1]>open, max(close[1]-open, high-low),
high-low),
iff(high-close<close-low, iff(close[1]>open, max(close[1]-low, high-close),
open-low),
iff(close[1]>open, max(close[1]-open, high-low),
iff(close[1]<open, max(open-low, high-close),
high-low))))))
TP = BP+SP
// RAW Pressure Volume Calculations
BPV = (BP/TP)*vol
SPV = (SP/TP)*vol
TPV = BPV+SPV
BPVavg = ema(ema(BPV,signal),signal)
SPVavg = ema(ema(SPV,signal),signal)
TPVavg = ema(wma(TPV,signal),signal)
//
VN = vol/ema(vol,long)
BPN = ((BP/ema(BP,long))*VN)*100
SPN = ((SP/ema(SP,long))*VN)*100
TPN = BPN+SPN
nbf = ema(wma(BPN,signal),signal)
nsf = ema(wma(SPN,signal),signal)
tpf = ema(wma(TPN,signal),signal)
ndif = nbf-nsf
//
BPc1 = BPV>SPV ? BPV : -abs(BPV)
BPc2 = BPN>SPN ? BPN : -abs(BPN)
SPc1 = SPV>BPV ? SPV : -abs(SPV)
SPc2 = SPN>BPN ? SPN : -abs(SPN)
BPcon = norm ? BPc2 : BPc1
SPcon = norm ? SPc2 : SPc1
BPAcon = norm ? nbf : BPVavg
SPAcon = norm ? nsf : SPVavg
TPAcon = norm ? tpf : TPVavg
// Volume Pressure Convergence Divergence by XeL_Arjona
vpo1 = vinv ? (( sum(BPVavg,long)-sum(SPVavg,long))/sum(TPVavg,long))*100 : ((BPVavg-SPVavg)/TPVavg)*100
vpo2 = vinv ? (( sum(nbf,long)-sum(nsf,long))/sum(tpf,long))*100 : ((nbf-nsf)/tpf)*100
vph = nz((vpo1 - vpo2),0)
// Plot Indicator
histC = vph > vph[1] ? blue:#BA00AA
Vpo1C = vpo1 > 0 ? green:red
Vpo2C = vpo2 > 0 ? green:red
plot(vmacd ? na:SPcon, color=red, title="SELLING", style=columns, linewidth=3, transp=80)
plot(vmacd ? na:BPcon, color=green, title="BUYING", style=columns, linewidth=3, transp=80)
plot(vmacd ? na:SPAcon, color=red, title="SPAvg", style=line, linewidth=2) //ema(BearPower*SPV,signal)
plot(vmacd ? na:BPAcon, color=green, title="BPAvg", style=line, linewidth=2) //ema(BullPower*BPV,signal)
plot(vmacd ? vpo1:na, color=Vpo1C,title="VPO1", style=line, linewidth=3)
plot(vmacd ? vpo2:na, color=Vpo2C,title="VPO2", style=line, linewidth=1)
plot(vmacd ? vph:na, color=histC, title="VPH", style=columns, linewidth=3, transp=90)
2번째 지표 : Buy or Sell Signal
Factor=input(3, minval=1,maxval = 140)
Pd=input(80, minval=1,maxval = 140)
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown
linecolor = Trend == 1 ? green : red
plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")
plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)
//plot(Trend==1 and Trend[1]==-1,color = linecolor, style = circles, linewidth = 3,title="Trend")
plotarrow(Trend == 1 and Trend[1] == -1 ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(Trend == -1 and Trend[1] == 1 ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)