OPEN-SOURCE SCRIPT

EMA HI/LO Cloud Shift + Extra EMA

53
//version=6
indicator("EMA HI/LO Cloud Shift + Extra EMA + Shift EMA Line", overlay=true, max_lines_count=6, max_labels_count=0)

// ------------------------
// Inputs
// ------------------------
emaLength = input.int(22, "Main EMA Length", minval=1, maxval=200)
emaLineColor = input.color(color.blue, "Main EMA Lines Color")

// Main Cloud colors
cloudAboveColor = input.color(color.new(color.green, 80), "Main Cloud Color (Price Above)")
cloudBelowColor = input.color(color.new(color.red, 80), "Main Cloud Color (Price Below)")
cloudInsideColor = input.color(color.new(color.orange, 80), "Main Cloud Color (Price Inside)")

// ------------------------
// Shift EMA (new logic)
// ------------------------
showShiftEMA = input.bool(true, "Show Shift EMA Line?")
shiftEMALength = input.int(26, "Shift EMA Length", minval=1, maxval=500)
shiftEMASource = input.source(close, "Shift EMA Source") // fully customizable source
shiftEMAColor = input.color(color.purple, "Shift EMA Color")
shiftEMAWide = input.int(2, "Shift EMA Line Width", minval=1, maxval=5)
shiftEMAOffset = input.int(0, "Shift EMA Offset", minval=-100, maxval=100)

// ------------------------
// Second EMA (independent)
// ------------------------
showSecondEMA = input.bool(true, "Show Second EMA?")
secondEMALength = input.int(200, "Second EMA Length", minval=1, maxval=1000)
secondEMAColor = input.color(color.yellow, "Second EMA Color")
secondEMAWide = input.int(2, "Second EMA Line Width", minval=1, maxval=5)

// ------------------------
// Main EMA Cloud Calculations
// ------------------------
emaHigh = ta.ema(high, emaLength)
emaLow = ta.ema(low, emaLength)

// ------------------------
// Main Cloud logic
// ------------------------
priceAboveMain = close > emaHigh
priceBelowMain = close < emaLow
priceInsideMain = not priceAboveMain and not priceBelowMain

cloudColorMain = priceAboveMain ? cloudAboveColor : priceBelowMain ? cloudBelowColor : cloudInsideColor

p1_main = plot(emaHigh, title="Main EMA High", color=emaLineColor, linewidth=2)
p2_main = plot(emaLow, title="Main EMA Low", color=emaLineColor, linewidth=2)
fill(p1_main, p2_main, color=cloudColorMain, title="Main EMA Cloud")

// ------------------------
// Shift EMA Line (replaces cloud offset)
// ------------------------
shiftEMA = ta.ema(shiftEMASource, shiftEMALength)
plot(showShiftEMA ? shiftEMA : na, title="Shift EMA Line", color=shiftEMAColor, linewidth=shiftEMAWide, offset=shiftEMAOffset)

// ------------------------
// Second EMA Plot (Independent)
// ------------------------
secondEMA = ta.ema(close, secondEMALength)
plot(showSecondEMA ? secondEMA : na, title="Second EMA", color=secondEMAColor, linewidth=secondEMAWide)

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。