예스스탁
예스스탁 답변
2022-09-29 14:48:09
안녕하세요
예스스탁입니다.
올려주신 내용은 저희가 변환해 드리기 어렵습니다.
업무상 일정시간이상 요구되는 내용은 저희가 답변을 드리기 어렵습니다.
또한 해당 언어에 능숙하지 않아 내용파악하는데 시간이 많이 소모되어
해당 언어는 간단한 내용이 아니면 변경해 드리기 어렵습니다.
도움을 드리지 못해 죄송합니다.
즐거운 하루되세요
> alltoone 님이 쓴 글입니다.
> 제목 : 문의 드립니다.
> 아래 트레이딩 뷰 지표식을 전환 부탁드립니다.
시스템 식도 들어 있는 듯 한데, 그냥 지표식만 가능하시면 부탁드려요.
감사합니다.
study(title="MA Ribbon R5.2 by JustUncleL", shorttitle="MA_RIBBON R5.2", overlay = true)
// Use Alternate Anchor TF for MAs
anchor = input(0,minval=0,title="Set to an Anchor TimeFrame in mins (0=none, 1D=1440, 1W=7200)")
showRibbon = input(false, title="Show Ribbon If Chart TF Greater Than Anchor TF")
// Fast MA - type, length
fastType = input(defval="EMA", title="Fast MA Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "LAGMA", "LINREG", "HullMA", "ZEMA", "TMA", "SSMA"])
fastLen = input(defval=50, title="Fast MA - Length", minval=1)
fastGamma = input(defval=0.33,title="Fast MA - Gamma for LAGMA")
// Medium MA - type, length
mediumType = input(defval="EMA", title="Medium MA Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "LAGMA", "LINREG","HullMA", "ZEMA", "TMA", "SSMA"])
mediumLen = input(defval=1, title="Medium MA - Length (1=disabled)", minval=1)
mediumGamma = input(defval=0.55,title="Medium MA - Gamma for LAGMA")
// Slow MA - type, length
slowType = input(defval="EMA", title="Slow MA Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "LAGMA", "LINREG", "HullMA", "ZEMA", "TMA", "SSMA"])
slowLen = input(defval=100, title="Slow MA - Length", minval=2)
slowGamma = input(defval=0.77,title="Slow MA - Gamma for LAGMA")
//
ma_src = input(close,title="MA Source")
sBars = input(false,title="Show Coloured Bars")
uGrabClr= input(false,title="Use Grab Bar 6-tone Colours, instead of Standard 3-tone")
uOpen = input(false,title="Candles must open and close outside ribbon Colouring" )
//
ShowMACross = input(false,title="Show MA Cross Alerts")
//
ShowSwing = input(false,title="Show Swing Alerts")
rFilter = input(false,title="Filter Swing Alerts to Ribbon Colour")
dFilter = input(false,title="Filter Swing Alerts to Fast MA Directional Slope")
//
// - INPUTS END
// Constants colours that include fully non-transparent option.
green100 = #008000FF
lime100 = #00FF00FF
red100 = #FF0000FF
blue100 = #0000FFFF
aqua100 = #00FFFFFF
darkred100 = #8B0000FF
gray100 = #808080FF
// - FUNCTIONS
// - variant(type, src, len, gamma)
// Returns MA input sellection variant, default to SMA if blank or typo.
// SuperSmoother filter
// © 2013 John F. Ehlers
variant_supersmoother(src,len) =>
a1 = exp(-1.414*3.14159 / len)
b1 = 2*a1*cos(1.414*3.14159 / len)
c2 = b1
c3 = (-a1)*a1
c1 = 1 - c2 - c3
v9 = 0.0
v9 := c1*(src + nz(src[1])) / 2 + c2*nz(v9[1]) + c3*nz(v9[2])
v9
variant_smoothed(src,len) =>
v5 = 0.0
v5 := na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len
v5
variant_zerolagema(src,len) =>
xLag = (len - 1) / 2
xEMA = (src + (src - src[xLag]))
v10 = ema(xEMA, len)
v10
variant_doubleema(src,len) =>
v2 = ema(src, len)
v6 = 2 * v2 - ema(v2, len)
v6
variant_tripleema(src,len) =>
v2 = ema(src, len)
v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential
v7
//calc Laguerre
variant_lag(p,g) =>
L0 = 0.0
L1 = 0.0
L2 = 0.0
L3 = 0.0
L0 := (1 - g)*p+g*nz(L0[1])
L1 := -g*L0+nz(L0[1])+g*nz(L1[1])
L2 := -g*L1+nz(L1[1])+g*nz(L2[1])
L3 := -g*L2+nz(L2[1])+g*nz(L3[1])
f = (L0 + 2*L1 + 2*L2 + L3)/6
f
// return variant, defaults to SMA
variant(type, src, len, g) =>
result = src
if len>1
result := type=="EMA" ? ema(src,len) :
type=="WMA" ? wma(src,len):
type=="VWMA" ? vwma(src,len) :
type=="SMMA" ? variant_smoothed(src,len) :
type=="DEMA" ? variant_doubleema(src,len):
type=="TEMA" ? variant_tripleema(src,len):
type=="LAGMA" ? variant_lag(src,g) :
type=="LINREG"? linreg(src,len,0) :
type=="HullMA"? wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) :
type=="SSMA" ? variant_supersmoother(src,len) :
type=="ZEMA" ? variant_zerolagema(src,len) :
type=="TMA" ? sma(sma(src,len),len) :
sma(src,len)
//end if
result
// - /variant
// - FUNCTIONS END
// Make sure we have minimum channel spread.
LengthSlow_ = slowLen //fastType==slowType?(slowLen-slowLen)<1?slowLen+1:slowLen : slowLen
//what is the 1st Anchor (normally current chart TF)
currentTFmins = isintraday ? interval : isdaily ? interval*1440 : isweekly ? interval*7200 : ismonthly ? interval*30240 : interval
// function to caculate multiplier from anchor time frame (TF is in mins)
multAnchor(anchor) =>
mult = 1
if isintraday
mult := anchor>0 ? (interval<=0 ? 1 : interval>=anchor? 1 : round(anchor/interval)) : 1
else
mult := anchor>0 ? isdaily ? (anchor<=1440 ? 1 : round(anchor/1440)) :
isweekly ? (anchor<=7200 ? 1 : round(anchor/7200)) :
ismonthly ? (anchor<=30240 ? 1 : round(anchor/30240)) : 1 : 1
//end if
mult
// get multipliers for each time frame
mult = multAnchor(anchor)
// Adjust MA lengths with Anchor multiplier
LengthFast = mult==1 ? fastLen : (fastLen*mult)
LengthMedium = mult==1 ? mediumLen : (mediumLen*mult)
LengthSlow = mult==1 ? LengthSlow_ : (LengthSlow_*mult)
//plotshape(interval,location=location.bottom)
// Get the two MAs
fastMA = variant(fastType,ma_src, LengthFast, fastGamma)
slowMA = variant(slowType,ma_src, LengthSlow, slowGamma)
mediumMA = mediumLen==1 ? na : variant(mediumType,ma_src, LengthMedium, mediumGamma)
showRibbonFlag = showRibbon or anchor==0 or currentTFmins<=anchor
fDirection = 0
sDirection = 0
//mDirection = 0
fDirection := hlc3 > fastMA ? 1 : hlc3 < fastMA ? -1 : nz(fDirection[1],1)
sDirection := hlc3 > slowMA ? 1 : hlc3 < slowMA ? -1 : nz(sDirection[1],1)
//mDirection := LengthMedium==1 ? na : hlc3 > mediumMA ? 1 : hlc3 < mediumMA ? -1 : nz(mDirection[1],1)
//Plot the Ribbon
fastMA_=plot( showRibbonFlag?fastMA:na,color=fDirection==1?green:red,style=line,join=true,linewidth=1,transp=20,title="Fast MA")
slowMA_=plot( showRibbonFlag?slowMA:na,color=sDirection==1?green:red,style=line,join=true,linewidth=1,transp=20,title="Slow MA")
plot( showRibbonFlag?mediumMA:na,color=sDirection==1?green:red,style=circles,join=true,linewidth=1,transp=20,title="Medium MA")
fcolor = fastMA>slowMA?green:red
fill(fastMA_,slowMA_,color=fcolor,transp=80,title="Ribbon Fill")
// Colour bars according to the close position relative to the MA sellected
// Or Grab candle colour code bars according to the close position relative to the MA sellected
grabcol = uGrabClr? close>=open? hlc3>fastMA and hlc3>slowMA and (not uOpen or (open>fastMA and open>slowMA))? lime100 :
hlc3<fastMA and hlc3<slowMA and (not uOpen or (open<fastMA and open<slowMA))? red100 : aqua100 :
hlc3>fastMA and hlc3>slowMA and (not uOpen or (open>fastMA and open>slowMA))? green100 :
hlc3<fastMA and hlc3<slowMA and (not uOpen or (open<fastMA and open<slowMA))? darkred100 : blue100 : na
grabcol := uGrabClr? grabcol : hlc3>fastMA and hlc3>slowMA and (not uOpen or (open>fastMA and open>slowMA))? lime100 :
hlc3<fastMA and hlc3<slowMA and (not uOpen or (open<fastMA and open<slowMA))? red100 : gray100
barcolor(showRibbonFlag and sBars and not ShowMACross?grabcol:na, title = "Bar Colours")
// Generate Alert Arrows
//
buy = 0
sell=0
buyT = 0
sellT =0
// Generate signal by Candle Colour
buy := grabcol==lime100 or grabcol==green100? (nz(buy[1])+1) : 0
sell := grabcol==red100 or grabcol==darkred100? (nz(sell[1])+1) : 0
// Trend Filter
buyT := buy==0? 0 : (rFilter and fastMA<slowMA) or (dFilter and falling(fastMA,2))? 0 : nz(buyT[1])+1
sellT := sell==0? 0 : (rFilter and fastMA>slowMA) or (dFilter and rising(fastMA,2))? 0 : nz(sellT[1])+1
// Exit conditions
exitbuy = nz(buyT[1])>0 and buyT==0
exitsell = nz(sellT[1])>0 and sellT==0
//
plotarrow(showRibbonFlag and ShowSwing and buyT==1 ?1:na, title="BUY Swing Arrow", colorup=lime, maxheight=60, minheight=50, transp=20)
plotarrow(showRibbonFlag and ShowSwing and sellT==1 ?-1:na, title="SELL Swing Arrow", colordown=red, maxheight=60, minheight=50, transp=20)
//
plotshape(showRibbonFlag and ShowSwing and exitbuy, title='BUY Exit', style=shape.xcross, location=location.belowbar, color=gray, text="Exit₩nBuy", offset=0,transp=0)
plotshape(showRibbonFlag and ShowSwing and exitsell, title='Sell Exit', style=shape.xcross, location=location.abovebar, color=gray, text="Exit₩nSell", offset=0,transp=0)
// MA trend bar color
TrendingUp = fastMA > slowMA
TrendingDown = fastMA < slowMA
barcolor(showRibbonFlag and sBars and ShowMACross? TrendingUp ? green : TrendingDown ? red : blue : na)
// MA cross alert
MAcrossing = cross(fastMA, slowMA) ? fastMA : na
plot(showRibbonFlag and ShowMACross? MAcrossing : na, style = cross, linewidth = 4,color=black)
// MA cross background color alert
Uptrend = TrendingUp and TrendingDown[1]
Downtrend = TrendingDown and TrendingUp[1]
bgcolor(showRibbonFlag and ShowMACross? Uptrend ? green : Downtrend ? red : na : na,transp=50)
// Buy and sell alert
XBuy = 0, XBuy := nz(XBuy[1])
XSell = 0, XSell := nz(XSell[1])
XBuy := TrendingUp and close > close[1] ? XBuy+1 : TrendingDown or XBuy==0? 0 : XBuy+1
XSell := TrendingDown and close < close[1] ? XSell+1 : TrendingUp or XSell==0? 0 : XSell+1
plotshape(showRibbonFlag and ShowMACross and XBuy==1? close: na, color=black, style=shape.triangleup, text="XBuy", location=location.bottom, size=size.small)
plotshape(showRibbonFlag and ShowMACross and XSell==1? close: na, color=black, style=shape.triangledown, text="XSell", location=location.top, size=size.small)
//
//plotshape(showRibbonFlag and ShowMACross and exitbuy, title='BUY Exit', style=shape.xcross, location=location.belowbar, color=gray, text="Exit₩nBuy", offset=0,transp=0)
//plotshape(showRibbonFlag and ShowMACross and exitsell, title='Sell Exit', style=shape.xcross, location=location.abovebar, color=gray, text="Exit₩nSell", offset=0,transp=0)
// Generate Alarms
alertcondition(showRibbonFlag and buyT==1,title="BUY Alert",message="BUY")
alertcondition(showRibbonFlag and sellT==1,title="SELL Alert",message="SELL")
alertcondition(showRibbonFlag and XBuy==1,title="X BUY Alert",message="X BUY")
alertcondition(showRibbonFlag and XSell==1,title="X SELL Alert",message="X SELL")
alertcondition(showRibbonFlag and exitbuy,title="BUY Exit Alert",message="ExitBuy")
alertcondition(showRibbonFlag and exitsell,title="SELL Exit Alert",message="ExitSell")
//eof