예스스탁
예스스탁 답변
2020-03-11 10:08:57
안녕하세요
예스스탁입니다.
1 지표
input : FromMonth(6),FromDay(1),FromYear(2018),ToMonth(1),ToDay(1),ToYea(9999),
bb_use_ema(false),bb_length (5),bb_mult(2.0),
fast_ma_len(2),
nLengthSlow (34),nLengthFast(5);
var : bb_source(0),bb_basis(0),fast_ma(0),dev(0),bb_dev_inner(0);
var : inner_high(0),inner_low(0),Hl2(0),xSMA1_hl2(0),xSMA2_hl2(0),xSMA1_SMA2(0);
var : AO(0),break_down(false),break_up(false),tx(0);
bb_source = C;
bb_basis = iff(bb_use_ema,ema(bb_source, bb_length), ma(bb_source, bb_length));
fast_ma = ema(bb_source, fast_ma_len);
dev = std(bb_source, bb_length);
bb_dev_inner = bb_mult * dev;
inner_high = bb_basis + bb_dev_inner;
inner_low = bb_basis - bb_dev_inner;
// Calculate Awesome Oscillator
hl2 = (H+L)/2;
xSMA1_hl2 = ma(hl2, nLengthFast);
xSMA2_hl2 = ma(hl2, nLengthSlow);
xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2;
// Calculate direction of AO
AO = iff(xSMA1_SMA2>=0,iff(xSMA1_SMA2 > xSMA1_SMA2[1], 1, 2),iff(xSMA1_SMA2 > xSMA1_SMA2[1], -1, -2));
// === PLOTTING ===
// plot BB basis
plot1(bb_basis,"Basis Line",red);
// plot BB upper and lower bands
plot2(inner_high,"Upper Band Inner",blue);
plot3(inner_low, "Lower Band Inner",blue);
// plot fast ma
plot4(fast_ma,"Fast EMA",black);
// Calc breakouts
break_down = crossdown(fast_ma, bb_basis) and close < bb_basis and abs(AO)==2;
break_up = crossup(fast_ma, bb_basis) and close > bb_basis and abs(AO)==1;
if break_down == true Then
{
tx = Text_New(sdate,stime,h,"▼");
Text_SetColor(tx,RED);
Text_SetStyle(tx,2,1);
}
if break_up == true Then
{
tx = Text_New(sdate,stime,l,"▲");
Text_SetColor(tx,GREEN);
Text_SetStyle(tx,2,0);
}
2 강조
input : FromMonth(6),FromDay(1),FromYear(2018),ToMonth(1),ToDay(1),ToYea(9999),
bb_use_ema(false),bb_length (5),bb_mult(2.0),
fast_ma_len(2),
nLengthSlow (34),nLengthFast(5);
var : bb_source(0),bb_basis(0),fast_ma(0),dev(0),bb_dev_inner(0);
var : inner_high(0),inner_low(0),Hl2(0),xSMA1_hl2(0),xSMA2_hl2(0),xSMA1_SMA2(0);
var : AO(0),break_down(false),break_up(false),tx(0);
bb_source = C;
bb_basis = iff(bb_use_ema,ema(bb_source, bb_length), ma(bb_source, bb_length));
fast_ma = ema(bb_source, fast_ma_len);
dev = std(bb_source, bb_length);
bb_dev_inner = bb_mult * dev;
inner_high = bb_basis + bb_dev_inner;
inner_low = bb_basis - bb_dev_inner;
// Calculate Awesome Oscillator
hl2 = (H+L)/2;
xSMA1_hl2 = ma(hl2, nLengthFast);
xSMA2_hl2 = ma(hl2, nLengthSlow);
xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2;
// Calculate direction of AO
AO = iff(xSMA1_SMA2>=0,iff(xSMA1_SMA2 > xSMA1_SMA2[1], 1, 2),iff(xSMA1_SMA2 > xSMA1_SMA2[1], -1, -2));
PlotPaintBar(H,L,"강조",iff(AO == 2, red,iff(AO == 1,green, blue)));
#barcolor(AO == 2 ? red: AO == 1 ? green : blue )
즐거운 하루되세요
> as8282 님이 쓴 글입니다.
> 제목 : 문의드립니다.
> 트레이딩 뷰를 참고하고있습니다.
하기 수식을 예스로 변환부탁드립니다.
( 참고 : https://www.tradingview.com/script/ibq1TYLX-BB-AO-STRAT/ )
strategy(shorttitle="BB+AO STRAT", title="BB+AO STRAT", overlay=true)
// === BACKTEST RANGE ===
FromMonth = input(defval = 6, title = "From Month", minval = 1)
FromDay = input(defval = 1, title = "From Day", minval = 1)
FromYear = input(defval = 2018, title = "From Year", minval = 2014)
ToMonth = input(defval = 1, title = "To Month", minval = 1)
ToDay = input(defval = 1, title = "To Day", minval = 1)
ToYear = input(defval = 9999, title = "To Year", minval = 2014)
// Bollinger Bands Inputs
bb_use_ema = input(false, title="Use EMA for Bollinger Band")
bb_length = input(5, minval=1, title="Bollinger Length")
bb_source = input(close, title="Bollinger Source")
bb_mult = input(2.0, title="Base Multiplier", minval=0.5, maxval=10)
// EMA inputs
fast_ma_len = input(2, title="Fast EMA length", minval=2)
// Awesome Inputs
nLengthSlow = input(34, minval=1, title="Awesome Length Slow")
nLengthFast = input(5, minval=1, title="Awesome Length Fast")
// Breakout Indicator Inputs
bb_basis = bb_use_ema ? ema(bb_source, bb_length) : sma(bb_source, bb_length)
fast_ma = ema(bb_source, fast_ma_len)
// Deviation
dev = stdev(bb_source, bb_length)
bb_dev_inner = bb_mult * dev
// Upper bands
inner_high = bb_basis + bb_dev_inner
// Lower Bands
inner_low = bb_basis - bb_dev_inner
// Calculate Awesome Oscillator
xSMA1_hl2 = sma(hl2, nLengthFast)
xSMA2_hl2 = sma(hl2, nLengthSlow)
xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2
// Calculate direction of AO
AO = xSMA1_SMA2>=0? xSMA1_SMA2 > xSMA1_SMA2[1] ? 1 : 2 : xSMA1_SMA2 > xSMA1_SMA2[1] ? -1 : -2
// === PLOTTING ===
// plot BB basis
plot(bb_basis, title="Basis Line", color=red, transp=10, linewidth=2)
// plot BB upper and lower bands
ubi = plot(inner_high, title="Upper Band Inner", color=blue, transp=10, linewidth=1)
lbi = plot(inner_low, title="Lower Band Inner", color=blue, transp=10, linewidth=1)
// center BB channel fill
fill(ubi, lbi, title="Center Channel Fill", color=silver, transp=90)
// plot fast ma
plot(fast_ma, title="Fast EMA", color=black, transp=10, linewidth=2)
// Calc breakouts
break_down = crossunder(fast_ma, bb_basis) and close < bb_basis and abs(AO)==2
break_up = crossover(fast_ma, bb_basis) and close > bb_basis and abs(AO)==1
// Show Break Alerts
plotshape(break_down, title="Breakout Down", style=shape.arrowdown, location=location.abovebar, size=size.auto, text="Sell", color=red, transp=0)
plotshape(break_up, title="Breakout Up", style=shape.arrowup, location=location.belowbar, size=size.auto, text="Buy", color=green, transp=0)
// === ALERTS ===
strategy.entry("L", strategy.long, when=(break_up and (time > timestamp(FromYear, FromMonth, FromDay, 00, 00)) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))
strategy.close("L", when=(break_down and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))
// === /PLOTTING ===
barcolor(AO == 2 ? red: AO == 1 ? green : blue )
// eof