// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.
0
at [Link]
// Join our channel for more free tools: [Link] DxB//@version=5
indicator("Xpips Trade Trend", overlay=true)
// --- Paramètres utilisateur ---
output_smoothing = [Link](10, "SR MA Length", minval=1)
trigger_smoothing = [Link](2, "Trigger Smoothing", minval=1)
atr_length = [Link](50, "ATR Length", minval=1)
range_multiplier = [Link](3, "Range Multiplier", minval=0.1)
// Choix entre MA direction ou MA cross
ma_type = [Link]("MA direction", "MA Type", options=["MA direction", "MA
cross"])
// --- Sentiment Range MA [ChartPrime] ---
simple_filter(float source, int length, bool duel_filter)=>
switch duel_filter
false => [Link](source, length)
true => [Link]([Link](source, length), length)
sr_ma(float source = close, int output_smoothing = 3, int trigger_smoothing = 1,
int atr_length = 50, float multiplier = 1, string range_switch = "Body", bool
duel_filter = false)=>
candle_top = range_switch != "Body" ? high : [Link](open, close)
candle_bottom = range_switch != "Body" ? low : [Link](open, close)
smooth_top = [Link](candle_top, trigger_smoothing)
smooth_bottom = [Link](candle_bottom, trigger_smoothing)
tr = candle_top - candle_bottom
atr = [Link](tr, atr_length)
var float sr_ma = na
var float current_range = na
var float top_range = na
var float bottom_range = na
flag = smooth_top > top_range or smooth_bottom < bottom_range or
na(current_range)
if flag
sr_ma := source
current_range := atr * multiplier
top_range := sr_ma + current_range
bottom_range := sr_ma - current_range
out = simple_filter(sr_ma, output_smoothing, duel_filter)
smooth_top_range = simple_filter(top_range, output_smoothing, duel_filter)
smooth_bottom_range = simple_filter(bottom_range, output_smoothing,
duel_filter)
[out, smooth_top_range, smooth_bottom_range]
// --- Smoothed Heiken Ashi ---
import wallneradam/TAExt/8
ha_smooth_length = [Link](10, "Smooth Length", minval=1, group="Before HA")
ha_smooth_ma_type = [Link]('DEMA', 'MA Type', options=['SMA', 'EMA', 'WMA',
"VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "SWMA", "SMMA",
"JMA", "DONCHIAN", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA"], group="Before HA")
ha_after_smooth_length = [Link](10, "After Smooth Length", minval=1,
group="After HA")
ha_after_smooth_ma_type = [Link]('DEMA', 'After MA Type', options=['SMA',
'EMA', 'WMA', "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA",
"SWMA", "SMMA", "JMA", "DONCHIAN", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA"],
group="After HA")
[o, h, l, c] = TAExt.heiken_ashi(smooth_length=ha_smooth_length,
smooth_ma_type=ha_smooth_ma_type, after_smooth_length=ha_after_smooth_length,
after_smooth_ma_type=ha_after_smooth_ma_type)
// --- Zero Lag Trend Signals ---
length = [Link](50, "Length", tooltip = "The Look-Back window for the Zero-Lag
EMA calculations", group = "Main Calculations")
mult = [Link](1.2, "Band Multiplier", tooltip = "This value controls the
thickness of the bands, a larger value makes the indicato less noisy", group =
"Main Calculations")
t1 = [Link]("1", "Time frame 1", group = "Extra Timeframes")
t2 = [Link]("3", "Time frame 2", group = "Extra Timeframes")
t3 = [Link]("5", "Time frame 3", group = "Extra Timeframes")
t4 = [Link]("15", "Time frame 4", group = "Extra Timeframes")
t5 = [Link]("60", "Time frame 5", group = "Extra Timeframes")
green = [Link](#00ffbb, "Bullish Color", group = "Appearance")
red = [Link](#ff1100, "Bearish Color", group = "Appearance")
src = close
lag = [Link]((length - 1) / 2)
zlema = [Link](src + (src - src[lag]), length)
volatility = [Link]([Link](length), length*3) * mult
var trend = 0
if [Link](close, zlema+volatility)
trend := 1
if [Link](close, zlema-volatility)
trend := -1
zlemaColor = trend == 1 ? [Link](green, 70) : [Link](red, 70)
m = plot(zlema, title="Zero Lag Basis", linewidth=2, color=zlemaColor)
upper = plot(trend == -1 ? zlema+volatility : na, style = plot.style_linebr, color
= [Link](red, 90), title = "Upper Deviation Band")
lower = plot(trend == 1 ? zlema-volatility : na, style = plot.style_linebr, color =
[Link](green, 90), title = "Lower Deviation Band")
fill(m, upper, (open + close) / 2, zlema+volatility, [Link](red, 90),
[Link](red, 70))
fill(m, lower, (open + close) / 2, zlema-volatility, [Link](green, 90),
[Link](green, 70))
plotshape([Link](trend, 0) ? zlema+volatility : na, "Bearish Trend",
[Link], [Link], red, text = "▼", textcolor = chart.fg_color,
size = [Link])
plotshape([Link](trend, 0) ? zlema-volatility : na, "Bullish Trend",
[Link], [Link], green, text = "▲", textcolor = chart.fg_color,
size = [Link])
plotchar([Link](close, zlema) and trend == 1 and trend[1] == 1 ? zlema-
volatility*1.5 : na, "Bullish Entry", "▲", [Link], green, size =
[Link])
plotchar([Link](close, zlema) and trend == -1 and trend[1] == -1 ?
zlema+volatility*1.5 : na, "Bearish Entry", "▼", [Link], red, size =
[Link])
s1 = [Link]([Link], t1, trend)
s2 = [Link]([Link], t2, trend)
s3 = [Link]([Link], t3, trend)
s4 = [Link]([Link], t4, trend)
s5 = [Link]([Link], t5, trend)
s1a = s1 == 1 ? "Bullish" : "Bearish"
s2a = s2 == 1 ? "Bullish" : "Bearish"
s3a = s3 == 1 ? "Bullish" : "Bearish"
s4a = s4 == 1 ? "Bullish" : "Bearish"
s5a = s5 == 1 ? "Bullish" : "Bearish"
if [Link]
var data_table = [Link](position=position.top_right, columns=2, rows=6,
bgcolor=chart.bg_color, border_width=1, border_color=chart.fg_color,
frame_color=chart.fg_color, frame_width=1)
[Link](data_table, text_halign=text.align_center, column=0, row=0,
text="Time Frame", text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=1, row=0,
text="Signal", text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=0, row=1, text=t1,
text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=1, row=1,
text=s1a, text_color=chart.fg_color, bgcolor=s1a == "Bullish" ? [Link](green,
70) : [Link](red, 70))
[Link](data_table, text_halign=text.align_center, column=0, row=2, text=t2,
text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=1, row=2,
text=s2a, text_color=chart.fg_color, bgcolor=s2a == "Bullish" ? [Link](green,
70) : [Link](red, 70))
[Link](data_table, text_halign=text.align_center, column=0, row=3, text=t3,
text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=1, row=3,
text=s3a, text_color=chart.fg_color, bgcolor=s3a == "Bullish" ? [Link](green,
70) : [Link](red, 70))
[Link](data_table, text_halign=text.align_center, column=0, row=4, text=t4,
text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=1, row=4,
text=s4a, text_color=chart.fg_color, bgcolor=s4a == "Bullish" ? [Link](green,
70) : [Link](red, 70))
[Link](data_table, text_halign=text.align_center, column=0, row=5, text=t5,
text_color=chart.fg_color)
[Link](data_table, text_halign=text.align_center, column=1, row=5,
text=s5a, text_color=chart.fg_color, bgcolor=s5a == "Bullish" ? [Link](green,
70) : [Link](red, 70))
/////////////////////////////////////////ALERTS FOR SMALL ARROWS (ENTRY SIGNALS)
alertcondition([Link](close, zlema) and trend == 1 and trend[1] == 1,
"Bullish Entry Signal",
message="Bullish Entry Signal detected. Consider entering a long position.")
alertcondition([Link](close, zlema) and trend == -1 and trend[1] == -1,
"Bearish Entry Signal",
message="Bearish Entry Signal detected. Consider entering a short position.")
/////////////////////////////////////////ALERTS FOR TREND CONDITIONS
alertcondition([Link](trend, 0), "Bullish Trend")
alertcondition([Link](trend, 0), "Bearish Trend")
alertcondition([Link](trend, 0), "(Bullish or Bearish) Trend")
alertcondition([Link](s1, 0), "Bullish Trend Time Frame 1")
alertcondition([Link](s1, 0), "Bearish Trend Time Frame 1")
alertcondition([Link](s1, 0), "(Bullish or Bearish) Trend Time Frame 1")
alertcondition([Link](s2, 0), "Bullish Trend Time Frame 2")
alertcondition([Link](s2, 0), "Bearish Trend Time Frame 2")
alertcondition([Link](s2, 0), "(Bullish or Bearish) Trend Time Frame 2")
alertcondition([Link](s3, 0), "Bullish Trend Time Frame 3")
alertcondition([Link](s3, 0), "Bearish Trend Time Frame 3")
alertcondition([Link](s3, 0), "(Bullish or Bearish) Trend Time Frame 3")
alertcondition([Link](s4, 0), "Bullish Trend Time Frame 4")
alertcondition([Link](s4, 0), "Bearish Trend Time Frame 4")
alertcondition([Link](s4, 0), "(Bullish or Bearish) Trend Time Frame 4")
alertcondition([Link](s5, 0), "Bullish Trend Time Frame 5")
alertcondition([Link](s5, 0), "Bearish Trend Time Frame 5")
alertcondition([Link](s5, 0), "(Bullish or Bearish) Trend Time Frame 5")
alertcondition([Link](close, zlema) and trend == 1 and trend[1] == 1,
"Bullish Entry")
alertcondition([Link](close, zlema) and trend == -1 and trend[1] == -1,
"Bearish Entry")
// --- Combine the Plots ---
[sr_ma_result, top_range, bottom_range] = sr_ma(close, output_smoothing,
trigger_smoothing, atr_length, range_multiplier, "Body", true)
// Calculer la direction (MA direction ou MA cross)
ma_direction = sr_ma_result > sr_ma_result[1] ? 1 : (sr_ma_result < sr_ma_result[1]
? -1 : 0)
color_sr_ma = ma_type == "MA direction" ? (ma_direction == 1 ? [Link] :
(ma_direction == -1 ? [Link] : [Link])) : na
plot(sr_ma_result, title="Sentiment Range MA", color=color_sr_ma, linewidth=2)
// Affichage des bougies Heiken Ashi
plotcandle(o, h, l, c, title="Smoothed Heiken Ashi",
color=o > c ? [Link]([Link], 60) : [Link]([Link], 60),
wickcolor=o > c ? [Link]([Link], 20) : [Link]([Link], 20),
bordercolor=o > c ? [Link]([Link], 10) : [Link]([Link], 10))
//
===================================================================================
=======