투자_주식 그리고 가상화폐/투자 메뉴얼
공포탐욕지수 보조지표(트레이딩뷰 pine에디터 붙여넣기 사용)
CallManager
2023. 11. 21. 23:00
study(title="Trading Psychology - Fear & Greed Index by DGT", shorttitle="CYCLE by DGT", format=format.percent, max_bars_back=252)
// -Inputs ====================================================================================== //
smoothLength = input(title="RMA Smoothing Length", type=input.integer, minval=1 , maxval=13 , defval=5)
faster = input(false)
fastLength = faster ? 13 : 21
slowLength = faster ? 89 : 144
// -Calculations ================================================================================ //
pmacd = security(syminfo.tickerid, "D", (close/ema(close, slowLength) - 1) * 100)
ror = security(syminfo.tickerid, "D", (close - close[slowLength])/close[slowLength] * 100)
accDist = security(syminfo.tickerid, "D", close==high and close==low or high==low ? 0 : ((2 * close - low - high) / (high - low)))
vol = security(syminfo.tickerid, "D", volume)
moneyFlow = if nz(vol) != 0
sum(accDist * vol, fastLength) / sum(vol, fastLength) * 100
vix = security ("VIX" , "D", -(close/ema(close, slowLength) - 1) * 100)
gold = security ("GOLD", "D", (1 - close[fastLength] / close) * 100)
cycle = if nz(vol) == 0
rma((pmacd + ror + vix + gold) / 4, smoothLength)
else
rma((pmacd + ror + moneyFlow + vix + gold) / 5, smoothLength)
// -Coloring ==================================================================================== //
var cycleColor = color.black
var ForG = ""
if cycle >= 50
cycleColor := #006400
ForG := "Extreame Greed"
else if cycle >= 35 and cycle < 50
cycleColor := color.green
ForG := "Greed"
else if cycle >= 20 and cycle < 35
cycleColor :=color.blue
ForG := "Greed"
else if cycle >= 5 and cycle < 20
cycleColor := color.aqua
ForG := "Neutral"
else if cycle < -5 and cycle >= -15
cycleColor := color.yellow
ForG := "Neutral"
else if cycle < -15 and cycle >= -25
cycleColor := color.orange
ForG := "Fear"
else if cycle < -25 and cycle >= -40
cycleColor := color.red
ForG := "Fear"
else if cycle < -40
cycleColor := #910000
ForG := "Extreame Fear"
else
cycleColor := color.gray
ForG := "Neutral"
// -Plotting ==================================================================================== //
plot(cycle, color=cycleColor, title="Psychology of The Market Cycle")
label fgiLabel = label.new(bar_index, cycle,
text=ForG + " : " + tostring(round(cycle)) + "%"
,tooltip="Psychology of The Market Cycle by DGT\n\n" +
"Fear & Greed Index : " + ForG + " : " + tostring(round(cycle)) + "%, Reference Sources : " +
"\n-------------------------------------------------------------------" +
"\n 1 - Price Convergence/Divergence to/from its Moving Average(" + tostring(slowLength) + ") : " + tostring(round(pmacd)) + "%" +
"\n 2 - Rate of Return (Momentum/RoC), Length (" + tostring(slowLength) + ") : " + tostring(round(ror)) + "%" +
"\n 3 - Chaikin Money Flow, Length (" + tostring(fastLength) + ") : " + tostring(round(moneyFlow)) + "% \n ps: cmf calculated only if volume data is provided" +
"\n 4 - VIX - Volatility (Fear) Index, Length (" + tostring(slowLength) + ") : " + tostring(round(vix)) + "%" +
"\n 5 - Safe Haven Demand - Gold Demand, Length (" + tostring(fastLength) + ") : " + tostring(round(gold)) + "%" +
"\n\nWarren Buffett’s quote, buy when others are fearful, and sell when others are greedy"
,color=cycleColor, style=label.style_label_left, textcolor=color.white, textalign=text.align_left)
label.delete(fgiLabel[1])
반응형