답변완료
안녕하세요 수식 좀 문의드립니다.
안녕하세요 수식 좀 문의 드립니다.
아래 코드에서 print문으로 엑셀에 데이터를 저장하고 있는데요
주로 실시간에서.. 차트는 5분봉으로 되어 있는데 5분마다 데이터가 들어오는게 아니고 불규칙적으로 데이터가 들어오는데 봉이 완성되는 5분마다만 데이터를 받게 수정할수 있을까요?
var : var11(0),var12(0),var13(0),var14(0),var15(0),var1(0),var2(0);
var : var21(0),var22(0),var23(0),var24(0),var25(0);
var : var31(0),var32(0),var33(0),var34(0),var35(0),var36(0);
input : StartDate(20240702),EndDate(20240814);
input : StartTime(090000),EndTime(150000);
var : Tcond(false);
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
}
if sDate >= StartDate and sDate <= EndDate and Tcond == true Then
{
var11 = Data2(c);
var12 = Data3(c);
var13 = Data4(c);
var14 = Data5(c);
var21 = Data6(c);
var22 = Data7(c);
var23 = Data8(c);
var24 = Asks;
var25 = Bids;
var31 = Upvol;
var32 = DownVol;
var33 = openinterest;
var34 = var33[1]-var33 ;
if (abs(Var21[1]-Var21)) < 50000 Then var15 =(Var21[1]-Var21); Else var15 =0;
var2= var11-Var32;
var1= var13-Var31;
#print("c:₩win₩data.csv",",날짜,%f,,시간,%f,,시,%.2f,,고,%.2f,,저,%.2f,,종,%.2f,,거래량,%f,,미결제,%f,,비차익,%f,,매수수량,%2f,,매수건수,%.f,,매도수량,%.f,,매도건수,%.f,,매도총건수,%.f,,매수총건수,%.f,,매도총수량,%.f,,매수총건수,%.f,,상승체결,%.f,,하락체결,%.f",sDate,sTime,O,H,L,C,V,var34,var15,var11,var12,var13,var14,var22,var23,var24,var25,var31,var32);
print("c:₩win₩data.csv",",거래량,%f,시,%.2f,고,%.2f,저,%.2f,종,%.2f,미결제,%f,비차익,%f,매수수량,%2f,매수건수,%.f,매도수량,%.f,매도건수,%.f,매도총건수,%.f,매수총건수,%.f,매도총수량,%.f,매수총건수,%.f,상승체결,%.f,하락체결,%.f,상승건수,%.f,하락건수,%.f,체결건수,%.f,상승제외,%.f,하락제외,%.f,",V,O,H,L,C,V,var34,var15,var11,var12,var13,var14,var22,var23,var24,var25,var31,var32,Upticks,Downticks,Ticks,Var1,Var2);
Plot1(var34, "미결제약정");
Plot2(var11,"매수5호가수량");
Plot3(var12,"매수5호가건수");
Plot4(var13,"매도호5호가수량");
Plot5(var14,"매도5호가건수");
Plot6(var15,"비차익");
Plot7(var22,"매도총건수");
Plot8(var23,"매수총건수");
Plot9(var24,"매도총수량");
Plot10(var25,"매수총건수");
Plot11(var31,"상승체결");
Plot12(var32,"하락체결");
#Plot13(var15, "비차익2");
}
2024-08-19
764
글번호 182604
지표
답변완료
부탁드립니다.
트레이딩뷰 지표인데 변환 부탁드립니다.
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)
2024-08-18
953
글번호 182592
지표