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提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。