Combined Equal-Length EMA/SMA Cross V1.1

Cryptoluc1d · study · 29 行 · 点赞 497 · TradingView 原页

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

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Cryptoluc1d
 
//@version=4
study("Combined Equal-Length EMA/SMA Cross", overlay=true)
 
// Create inputs
mom_length = input(title="Momentum Length (EMA=SMA)", defval=50)
bias_length  = input(title="Bias SMA Length", defval=100)
 
// Define MAs
ema = ema(close, mom_length)
sma = sma(close, mom_length)
combined_ma = ema
bias_ma = sma(close, bias_length)
 
// Allow option to show combined or separate MAs
show_all_ma = input(title="Show All MAs Separately", defval=false)
 
// Color the MAs
combined_ma_color = (ema > sma and ema > bias_ma) ? color.green 
                  : (ema < sma and ema < bias_ma) ? color.red
                  : color.yellow
 
// Plot MAs
plot(show_all_ma ? na : combined_ma, title="Combined Momentum MA", color=combined_ma_color, linewidth=3)
plot(show_all_ma ? ema : na, title="Momentum EMA", color=color.green, linewidth=1)
plot(show_all_ma ? sma : na, title="Momentum SMA", color=color.yellow, linewidth=1)
plot(show_all_ma ? bias_ma : na, title="Bias SMA", color=color.red, linewidth=2)

← 返回列表