OPEN-SOURCE SCRIPT

EUR/USD Morning Strategy with Trade History

//version=5
indicator("EUR/USD Morning Strategy with Trade History", overlay=true)

// Inputs for customization
ema_fast = input.int(8, title="Fast EMA")
ema_slow = input.int(21, title="Slow EMA")
rsi_period = input.int(14, title="RSI Period")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")
atr_period = input.int(14, title="ATR Period")
take_profit_multiplier = input.float(1.5, title="Take Profit Multiplier (ATR)")
stop_loss_multiplier = input.float(1.0, title="Stop Loss Multiplier (ATR)")
time_filter_start = input.time(timestamp("0000-01-01 08:00 +0000"), title="Trading Start Time")
time_filter_end = input.time(timestamp("0000-01-01 16:00 +0000"), title="Trading End Time")

// Calculate EMAs
fastEMA = ta.ema(close, ema_fast)
slowEMA = ta.ema(close, ema_slow)

// Calculate RSI
rsi = ta.rsi(close, rsi_period)

// Calculate ATR
atr = ta.atr(atr_period)

// Time filter
in_session = (time >= time_filter_start) and (time <= time_filter_end)

// Entry Conditions
buy_signal = ta.crossover(fastEMA, slowEMA) and rsi > 50 and in_session
sell_signal = ta.crossunder(fastEMA, slowEMA) and rsi < 50 and in_session

// Exit conditions (calculated but not triggered in this script)
long_take_profit = close + (atr * take_profit_multiplier)
long_stop_loss = close - (atr * stop_loss_multiplier)

short_take_profit = close - (atr * take_profit_multiplier)
short_stop_loss = close + (atr * stop_loss_multiplier)

// Arrays to track historical trades
var float[] long_trade_entries = array.new_float(0)
var float[] short_trade_entries = array.new_float(0)

if (buy_signal)
array.push(long_trade_entries, close)

if (sell_signal)
array.push(short_trade_entries, close)

// Plot EMAs
plot(fastEMA, color=color.green, title="Fast EMA (8)")
plot(slowEMA, color=color.red, title="Slow EMA (21)")

// Plot Buy and Sell Markers
plotshape(series=buy_signal, location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, title="Buy Signal")
plotshape(series=sell_signal, location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, title="Sell Signal")

// Plot Take Profit and Stop Loss Levels for Visuals
plotshape(series=buy_signal, location=location.abovebar, offset=-1, color=color.new(color.blue, 0), style=shape.triangleup, title="Take Profit (Buy)")
plotshape(series=buy_signal, location=location.belowbar, offset=-1, color=color.new(color.orange, 0), style=shape.triangledown, title="Stop Loss (Buy)")

plotshape(series=sell_signal, location=location.belowbar, offset=-1, color=color.new(color.blue, 0), style=shape.triangledown, title="Take Profit (Sell)")
plotshape(series=sell_signal, location=location.abovebar, offset=-1, color=color.new(color.orange, 0), style=shape.triangleup, title="Stop Loss (Sell)")

// Highlight Session for Better Visualization
bgcolor(in_session ? color.new(color.green, 90) : na, title="Session Background")
Candlestick analysisChart patternsCycles

Skrypt open-source

W prawdziwym duchu TradingView autor tego skryptu opublikował go jako open source, aby inwestorzy mogli go zrozumieć i zweryfikować. Pozdrowienia dla autora! Możesz go używać bezpłatnie, ale ponowne użycie tego kodu w publikacji podlega Zasadom Regulaminu. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Chcesz użyć tego skryptu na wykresie?

Wyłączenie odpowiedzialności