WTI TRADE 15M - BY JJS TRADER

JOMTRADEFCPO · study · 214 行 · 点赞 42 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("JJS WTI 15M - 3D Visual Edition", shorttitle="JJS WTI 3D", overlay=false)
 
//====================================================
// 1. DEMA SETTINGS
//====================================================
groupDEMA = "DEMA Settings"
 
showDEMA = input.bool(true, "Show DEMA Lines", group=groupDEMA)
showGlow = input.bool(true, "Enable 3D Glow Effect", group=groupDEMA)
 
dema85HighColor = input.color(color.lime, "DEMA 85 High", group=groupDEMA)
dema85LowColor = input.color(color.red, "DEMA 85 Low", group=groupDEMA)
dema85OpenColor = input.color(color.orange, "DEMA 85 Open", group=groupDEMA)
dema190Color = input.color(color.white, "DEMA 190 Close", group=groupDEMA)
 
demaWidth = input.int(2, "Line Width", minval=1, maxval=5, group=groupDEMA)
 
// DEMA CALCULATION
dema(src, length) =>
    ema1 = ta.ema(src, length)
    ema2 = ta.ema(ema1, length)
    2.0 * ema1 - ema2
 
demaHigh = dema(high, 85)
demaLow = dema(low, 85)
demaOpen = dema(open, 85)
dema190 = dema(close, 190)
 
// DEMA 85 HIGH GLOW
plot(showDEMA and showGlow ? demaHigh : na, "High Outer Glow", color=color.new(dema85HighColor, 88), linewidth=8, force_overlay=true)
plot(showDEMA and showGlow ? demaHigh : na, "High Inner Glow", color=color.new(dema85HighColor, 72), linewidth=5, force_overlay=true)
 
// DEMA 85 LOW GLOW
plot(showDEMA and showGlow ? demaLow : na, "Low Outer Glow", color=color.new(dema85LowColor, 88), linewidth=8, force_overlay=true)
plot(showDEMA and showGlow ? demaLow : na, "Low Inner Glow", color=color.new(dema85LowColor, 72), linewidth=5, force_overlay=true)
 
// DEMA 85 OPEN GLOW
plot(showDEMA and showGlow ? demaOpen : na, "Open Outer Glow", color=color.new(dema85OpenColor, 88), linewidth=8, force_overlay=true)
plot(showDEMA and showGlow ? demaOpen : na, "Open Inner Glow", color=color.new(dema85OpenColor, 72), linewidth=5, force_overlay=true)
 
// DEMA 190 GLOW
plot(showDEMA and showGlow ? dema190 : na, "190 Outer Glow", color=color.new(dema190Color, 88), linewidth=8, force_overlay=true)
plot(showDEMA and showGlow ? dema190 : na, "190 Inner Glow", color=color.new(dema190Color, 72), linewidth=5, force_overlay=true)
 
// MAIN DEMA LINES
plot(showDEMA ? demaHigh : na, "DEMA 85 High", color=dema85HighColor, linewidth=demaWidth, force_overlay=true)
plot(showDEMA ? demaLow : na, "DEMA 85 Low", color=dema85LowColor, linewidth=demaWidth, force_overlay=true)
plot(showDEMA ? demaOpen : na, "DEMA 85 Open", color=dema85OpenColor, linewidth=demaWidth, force_overlay=true)
plot(showDEMA ? dema190 : na, "DEMA 190 Close", color=dema190Color, linewidth=demaWidth, force_overlay=true)
 
 
//====================================================
// 2. BOLLINGER BANDS
//====================================================
groupBB = "Bollinger Bands"
 
showBB = input.bool(true, "Show Bollinger Bands", group=groupBB)
showBBGlow = input.bool(true, "Enable BB Glow", group=groupBB)
 
bbLength = input.int(22, "Length", minval=1, group=groupBB)
bbMult = input.float(2.0, "Standard Deviation", minval=0.1, step=0.1, group=groupBB)
 
bbColor = input.color(color.blue, "Band Color", group=groupBB)
bbWidth = input.int(1, "Band Width", minval=1, maxval=5, group=groupBB)
bbFillTransparency = input.int(92, "Fill Transparency", minval=0, maxval=100, group=groupBB)
 
bbBasis = ta.sma(close, bbLength)
bbDeviation = bbMult * ta.stdev(close, bbLength)
 
bbUpper = bbBasis + bbDeviation
bbLower = bbBasis - bbDeviation
 
// BB GLOW
plot(showBB and showBBGlow ? bbUpper : na, "BB Upper Glow", color=color.new(bbColor, 88), linewidth=8, force_overlay=true)
plot(showBB and showBBGlow ? bbLower : na, "BB Lower Glow", color=color.new(bbColor, 88), linewidth=8, force_overlay=true)
 
// MAIN BB
pUpper = plot(showBB ? bbUpper : na, "BB Upper", color=bbColor, linewidth=bbWidth, force_overlay=true)
pLower = plot(showBB ? bbLower : na, "BB Lower", color=bbColor, linewidth=bbWidth, force_overlay=true)
 
fill(pUpper, pLower, color=showBB ? color.new(bbColor, bbFillTransparency) : na, title="BB Fill")
 
 
//====================================================
// 3. cRSI SETTINGS
//====================================================
groupCRSI = "cRSI Settings"
 
showCRSI = input.bool(true, "Show cRSI", group=groupCRSI)
showCRSIGlow = input.bool(true, "Enable cRSI Glow", group=groupCRSI)
 
domcycle = input.int(15, "Dominant Cycle Length", minval=10, group=groupCRSI)
vibration = input.int(10, "Vibration", minval=1, group=groupCRSI)
leveling = input.float(10.0, "Leveling", minval=1, maxval=50, group=groupCRSI)
 
fixedOS = input.float(30.0, "Oversold Level", group=groupCRSI)
fixedOB = input.float(70.0, "Overbought Level", group=groupCRSI)
 
crsiColor = input.color(color.fuchsia, "cRSI Color", group=groupCRSI)
bandColor = input.color(color.aqua, "Dynamic Band Color", group=groupCRSI)
levelColor = input.color(color.silver, "OS / OB Line Color", group=groupCRSI)
 
crsiWidth = input.int(2, "cRSI Line Width", minval=1, maxval=5, group=groupCRSI)
showCRSIFill = input.bool(true, "Show Dynamic Band Fill", group=groupCRSI)
 
// ORIGINAL cRSI CALCULATION
src = close
 
cyclelen = math.max(1, int(domcycle / 2))
cyclicmemory = domcycle * 2
 
torque = 2.0 / (vibration + 1)
phasingLag = int((vibration - 1) / 2.0)
 
up = ta.rma(math.max(ta.change(src), 0), cyclelen)
down = ta.rma(-math.min(ta.change(src), 0), cyclelen)
 
rsiValue = down == 0 ? 100.0 : up == 0 ? 0.0 : 100.0 - 100.0 / (1.0 + up / down)
 
var float crsi = 0.0
 
crsi := torque * (2.0 * rsiValue - nz(rsiValue[phasingLag])) + (1.0 - torque) * nz(crsi[1])
 
 
//====================================================
// 4. ORIGINAL DYNAMIC LOWBAND / HIGHBAND
//====================================================
float lmax = -999999.0
float lmin = 999999.0
 
for i = 0 to cyclicmemory - 1
    if nz(crsi[i], -999999.0) > lmax
        lmax := nz(crsi[i])
    else
        if nz(crsi[i], 999999.0) < lmin
            lmin := nz(crsi[i])
 
mstep = (lmax - lmin) / 100.0
aperc = leveling / 100.0
 
float db = 0.0
 
for steps = 0 to 100
    testvalue = lmin + mstep * steps
    float below = 0.0
 
    for m = 0 to cyclicmemory - 1
        below += nz(crsi[m]) < testvalue ? 1.0 : 0.0
 
    ratio = below / cyclicmemory
 
    if ratio >= aperc
        db := testvalue
        break
 
float ub = 0.0
 
for steps = 0 to 100
    testvalue = lmax - mstep * steps
    float above = 0.0
 
    for m = 0 to cyclicmemory - 1
        above += nz(crsi[m]) >= testvalue ? 1.0 : 0.0
 
    ratio = above / cyclicmemory
 
    if ratio >= aperc
        ub := testvalue
        break
 
lowband = db
highband = ub
 
 
//====================================================
// 5. cRSI DISPLAY
//====================================================
hOS = hline(30, "Oversold 30", color=levelColor, linestyle=hline.style_dashed)
hOB = hline(70, "Overbought 70", color=levelColor, linestyle=hline.style_dashed)
 
// DYNAMIC BANDS
pLow = plot(showCRSI ? lowband : na, "LowBand", color=bandColor)
pHigh = plot(showCRSI ? highband : na, "HighBand", color=bandColor)
 
fill(pLow, pHigh, color=showCRSI and showCRSIFill ? color.new(color.gray, 90) : na, title="Dynamic Band Fill")
 
fill(hOS, hOB, color=color.new(color.silver, 94), title="Fixed OS OB Zone")
 
// cRSI OUTER GLOW
plot(showCRSI and showCRSIGlow ? crsi : na, "cRSI Outer Glow", color=color.new(crsiColor, 85), linewidth=8)
 
// cRSI INNER GLOW
plot(showCRSI and showCRSIGlow ? crsi : na, "cRSI Inner Glow", color=color.new(crsiColor, 65), linewidth=5)
 
// MAIN cRSI
plot(showCRSI ? crsi : na, "CRSI", color=crsiColor, linewidth=crsiWidth)
 
 
//====================================================
// 6. ORIGINAL AUTHOR ACKNOWLEDGEMENT
//====================================================
// Original Author: Lars von Thienen (whentotrade)
// Year: 2017
// Original Work:
// Decoding The Hidden Market Rhythm - Part 1:
// Dynamic Cycles (2017), Chapter 4.
//
// License: Creative Commons Attribution 4.0
// https://creativecommons.org/licenses/by/4.0/
//
// Original cRSI calculation adapted and integrated
// into WTI TF 15M ONLY by JJS Trader.
//====================================================

← 返回列表