예스스탁
예스스탁 답변
2024-12-23 14:22:26
안녕하세요
예스스탁입니다.
input : fib1(1.618);
input : fib2(2.618);
input : dev(150);
var : debut(False);
var : addsource(0),addvol(0),VWAP(0),sn(0),sd(0);
var : Fibp2(0),Fibp1(0),Fibm1(0),Fibm2(0),tx(0);
debut = DayOfWeek(Bdate) < DayOfWeek(Bdate[1]);
addsource = (h+l+c)/3 * volume;
addvol = volume;
if debut == true Then
{
var1 = addsource;
var2 = addvol;
}
Else
{
var1 = var1 + addsource;
var2 = var2 + addvol;
}
VWAP = var1/var2;
if debut Then
sn = 0;
sn = iff(debut , sn , sn[1] + volume * ((h+l+c)/3 - VWAP[1]) * ((h+l+c)/3 - VWAP));
sd = sqrt(sn / addvol);
Fibp2 = VWAP + fib2 * sd;
Fibp1 = VWAP + fib1 * sd;
Fibm1 = VWAP - fib1 * sd;
Fibm2 = VWAP - fib2 * sd;
plot1(VWAP, "VWAP",orange);
plot2(Fibp2,"Fibp2",red);
plot3(Fibp1,"Fibp1",red);
plot4(Fibm1,"Fibm1",lime);
plot5(Fibm2,"Fibm2",lime);
var : bull(False),bear(False);
bull = CrossDown(low[1],Fibm1[1]) and low[1]>=Fibm2[1] and low>Fibm2 and low<Fibm1 and sd>dev;
bear = CrossUp(high[1],Fibp1[1]) and high[1]<=Fibp2[1] and high<Fibp2 and high>Fibp1 and sd>dev;
if bull == true Then
{
tx = Text_New(sDate,sTime,L,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Red);
Text_SetSize(tx,20);
}
if bear == true Then
{
tx = Text_New(sDate,sTime,H,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,Blue);
Text_SetSize(tx,20);
}
즐거운 하루되세요
> 고저중 님이 쓴 글입니다.
> 제목 : 변환 부탁드립니다
> //@version=4
strategy(title="VWAP + Fibo Dev Extensions Strategy", overlay=true, pyramiding=5, commission_value=0.08)
// -------------------------------------
// ------- Inputs Fibos Values ---------
// -------------------------------------
fib1 = input(title="Fibo extension 1", type=input.float, defval=1.618)
fib2 = input(title="Fibo extension 2", type=input.float, defval=2.618)
reso = input(title="Resolution VWAP", type=input.resolution, defval="W")
dev = input(title="Deviation value min.", type=input.integer, defval=150)
// -------------------------------------
// -------- VWAP Calculations ----------
// -------------------------------------
t = time(reso)
debut = na(t[1]) or t > t[1]
addsource = hlc3 * volume
addvol = volume
addsource := debut ? addsource : addsource + addsource[1]
addvol := debut ? addvol : addvol + addvol[1]
VWAP = addsource / addvol
sn = 0.0
sn := debut ? sn : sn[1] + volume * (hlc3 - VWAP[1]) * (hlc3 - VWAP)
sd = sqrt(sn / addvol)
Fibp2 = VWAP + fib2 * sd
Fibp1 = VWAP + fib1 * sd
Fibm1 = VWAP - fib1 * sd
Fibm2 = VWAP - fib2 * sd
// -------------------------------------
// -------------- Plots ----------------
// -------------------------------------
plot(VWAP, title="VWAP", color=color.orange)
pFibp2 = plot(Fibp2, color=color.red)
pFibp1 = plot(Fibp1, color=color.red)
pFibm1 = plot(Fibm1, color=color.lime)
pFibm2 = plot(Fibm2, color=color.lime)
fill(pFibp2,pFibp1, color.red)
fill(pFibm2,pFibm1, color.lime)
// -------------------------------------
// ------------ Positions --------------
// -------------------------------------
bull = crossunder(low[1],Fibm1[1]) and low[1]>=Fibm2[1] and low>Fibm2 and low<Fibm1 and sd>dev
bear = crossover(high[1],Fibp1[1]) and high[1]<=Fibp2[1] and high<Fibp2 and high>Fibp1 and sd>dev
//plotshape(bear, title='Bear', style=shape.triangledown, location=location.abovebar, color=color.red, offset=0)
//plotshape(bull, title='Bull', style=shape.triangleup, location=location.belowbar, color=color.green, offset=0)
// -------------------------------------
// --------- Strategy Orders -----------
// -------------------------------------
strategy.entry("Long", true, when = bull)
strategy.close("Long", when = crossover(high,VWAP) or crossunder(low,Fibm2))
strategy.entry("Short", false, when = bear)
strategy.close("Short", when = crossunder(low,VWAP) or crossover(high,Fibp2))