Trend Indicator A (v2.3)

DZIV · study · 81 行 · 点赞 9,908 · TradingView 原页

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

Pine Script

//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
 
//————————————————————————————————————————————————————————————————————————————
//——————————————————————————— Auteur | © Dziwne ——————————————————————————————
//————————————————————————————————————————————————————————————————————————————
 
study(title="Trend Indicator A-V2 (Smoothed Heikin Ashi Cloud) [Dziwne]", shorttitle="Dziwne Trend Indicator A-V2 [Dziwne]", overlay=true)
 
//————————————————————————————————————————————————————————————————————————————
//—————————————————————————————— I. Paramètres ———————————————————————————————
//————————————————————————————————————————————————————————————————————————————
 
ema = input(defval=14, minval=1, title="EMA Length")
ema_smooth = input(defval=14, minval=1, title="EMA Length (Smoothing)")
 
colors = input(title = "Color Scheme", defval="Classic", options=["Classic", "Dziwne Color Scheme"])
show_line = input(false, "Show Lines")
show_hl = input(true, "Show High & Low cloud")
 
//————————————————————————————————————————————————————————————————————————————
//——————————————————————————— II.1. Calcules, EMA ————————————————————————————
//————————————————————————————————————————————————————————————————————————————
 
o = ema(open, ema)
c = ema(close, ema)
h = ema(high, ema)
l = ema(low, ema)
 
//————————————————————————————————————————————————————————————————————————————
//————————————————————————— II.2. Calcules, Heikin Ashi ——————————————————————
//————————————————————————————————————————————————————————————————————————————
 
ha_t = heikinashi(syminfo.tickerid)
 
ha_o = security(ha_t, timeframe.period, o)
ha_c = security(ha_t, timeframe.period, c)
ha_h = security(ha_t, timeframe.period, h)
ha_l = security(ha_t, timeframe.period, l)
 
//————————————————————————————————————————————————————————————————————————————
//————————————————— II.3. Calcules, EMA (Réduction du bruit) —————————————————
//————————————————————————————————————————————————————————————————————————————
 
ha_o_smooth = ema(ha_o, ema_smooth)
ha_c_smooth = ema(ha_c, ema_smooth)
ha_h_smooth = ema(ha_h, ema_smooth)
ha_l_smooth = ema(ha_l, ema_smooth)
 
dif_ha_oc_smooth = ha_c_smooth - ha_o_smooth
 
//————————————————————————————————————————————————————————————————————————————
//————————————————— II.4. Calcules, Définition des couleurs ——————————————————
//————————————————————————————————————————————————————————————————————————————
 
couleur_positive = colors == "Classic" ? #26A69A : #FFBE3D
couleur_negative = colors == "Classic" ? #EF5350 : #D63031
 
couleur_trend = dif_ha_oc_smooth <= 0 ? couleur_negative : couleur_positive
 
couleur_show_line_positive = show_line ? couleur_positive : na
couleur_show_line_negative = show_line ? couleur_negative : na
couleur_show_line_trend = show_line ? couleur_trend : na
 
couleur_show_hl = show_hl ? #808080 : na
 
//————————————————————————————————————————————————————————————————————————————
//———————————————————————————— III. Mise en place ————————————————————————————
//————————————————————————————————————————————————————————————————————————————
 
o_line = plot(ha_o_smooth, color=couleur_show_line_trend, title="Open Line")
c_line = plot(ha_c_smooth, color=couleur_show_line_trend, title="Close Line")
h_line = plot(ha_h_smooth, color=couleur_show_line_positive, title="High Line")
l_line = plot(ha_l_smooth, color=couleur_show_line_negative, title="Low Line")
 
fill(o_line, c_line, color=couleur_trend, transp=50, title="Open/Close Trendcloud")
fill(h_line, l_line, color=couleur_show_hl, transp=80, title="High/Low Trendcloud")
 
//————————————————————————————————————————————————————————————————————————————
//—————————————————————————————————— FIN —————————————————————————————————————
//————————————————————————————————————————————————————————————————————————————

← 返回列表