OPEN-SOURCE SCRIPT

EUR/USD Multi-Indicator Trading Strategy

//version=5
indicator("EUR/USD Multi-Indicator Trading Strategy", overlay=true)

// Input parameters
shortMA_length = input(10, title="Short MA Length")
longMA_length = input(50, title="Long MA Length")
rsi_length = input(14, title="RSI Length")
rsi_overbought = input(70, title="RSI Overbought Level")
rsi_oversold = input(30, title="RSI Oversold Level")
macd_fast_length = input(12, title="MACD Fast Length")
macd_slow_length = input(26, title="MACD Slow Length")
macd_signal_length = input(9, title="MACD Signal Length")
bollinger_length = input(20, title="Bollinger Bands Length")
bollinger_std_dev = input(2.0, title="Bollinger Bands Standard Deviation")
stoch_k_length = input(14, title="Stochastic %K Length")
stoch_d_length = input(3, title="Stochastic %D Length")

// Moving Averages
shortMA = ta.sma(close, shortMA_length)
longMA = ta.sma(close, longMA_length)
plot(shortMA, color=color.red, title="Short MA")
plot(longMA, color=color.blue, title="Long MA")

// RSI
rsi = ta.rsi(close, rsi_length)
hline(rsi_overbought, "Overbought", color=color.red)
hline(rsi_oversold, "Oversold", color=color.green)

// MACD
[macdLine, signalLine, _] = ta.macd(close, macd_fast_length, macd_slow_length, macd_signal_length)

// Bollinger Bands
basis = ta.sma(close, bollinger_length)
dev = bollinger_std_dev * ta.stdev(close, bollinger_length)
upperBand = basis + dev
lowerBand = basis - dev
plot(upperBand, color=color.green, title="Upper Band")
plot(lowerBand, color=color.red, title="Lower Band")

// Stochastic
k = ta.stoch(close, high, low, stoch_k_length)
d = ta.sma(k, stoch_d_length) // คำนวณ %D
hline(80, "Stochastic Overbought", color=color.red)
hline(20, "Stochastic Oversold", color=color.green)

// Buy and Sell Conditions
buyCondition = ta.crossover(shortMA, longMA) and rsi < rsi_oversold and (macdLine > signalLine) and (close <= lowerBand) and (k < 20 and ta.crossover(k, d))
sellCondition = ta.crossunder(shortMA, longMA) and rsi > rsi_overbought and (macdLine < signalLine) and (close >= upperBand) and (k > 80 and ta.crossunder(k, d))

// Plot Buy and Sell signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
Bands and ChannelsBill Williams IndicatorsBreadth Indicatorsstrategytrading

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian