OPEN-SOURCE SCRIPT
EMA HI/LO Cloud Shift + Extra EMA

//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)
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的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。