OPEN-SOURCE SCRIPT

Trend-Based Buy/Sell Signals

//version=5
indicator("Trend-Based Buy/Sell Signals", overlay=true)

// Input parameters
ema_short = input(9, title="Short EMA")
ema_long = input(21, title="Long EMA")

// Calculating EMAs
ema1 = ta.ema(close, ema_short)
ema2 = ta.ema(close, ema_long)

// Define buy and sell conditions
buy_condition = ta.crossover(ema1, ema2) // Short EMA crosses above Long EMA
sell_condition = ta.crossunder(ema1, ema2) // Short EMA crosses below Long EMA

// Plot EMAs
plot(ema1, color=color.green, title="Short EMA")
plot(ema2, color=color.red, title="Long EMA")

// Buy and Sell Signals
bgcolor(buy_condition ? color.new(color.green, 90) : na, title="Buy Signal Background")
bgcolor(sell_condition ? color.new(color.red, 90) : na, title="Sell Signal Background")
plotshape(series=buy_condition, style=shape.labelup, color=color.green, location=location.belowbar, title="Buy Signal")
plotshape(series=sell_condition, style=shape.labeldown, color=color.red, location=location.abovebar, title="Sell Signal")

// Basic Trend Visualization
high_line = ta.highest(high, 50)
low_line = ta.lowest(low, 50)
plot(high_line, color=color.blue, linewidth=2, title="High Trend Line")
plot(low_line, color=color.orange, linewidth=2, title="Low Trend Line")

// Alerts
alertcondition(buy_condition, title="Buy Alert", message="Buy Signal Triggered!")
alertcondition(sell_condition, title="Sell Alert", message="Sell Signal Triggered!")
Chart patterns

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?

Clause de non-responsabilité