OPEN-SOURCE SCRIPT
5-Min Gold Scalping Strategy with 1:3 RR

//version=5
strategy("5-Min Gold Scalping Strategy with 1:3 RR", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=2)
// Trend Direction (Using 15-Minute Price Action)
higherHigh = ta.highest(high, 5)
higherLow = ta.highest(low, 5)
lowerHigh = ta.lowest(high, 5)
lowerLow = ta.lowest(low, 5)
trendUp_15min = request.security(syminfo.tickerid, "15", higherHigh > higherHigh[1] and higherLow > higherLow[1])
trendDown_15min = request.security(syminfo.tickerid, "15", lowerHigh < lowerHigh[1] and lowerLow < lowerLow[1])
// Price Action on 5-Minute Chart
// Support/Resistance (Swing Lows/Highs)
swing_low = ta.lowest(low, 5)
swing_high = ta.highest(high, 5)
// Candlestick Patterns (Bullish/Bearish Engulfing)
bullishEngulfing = close > open and close[1] < open[1] and close > high[1] and open < low[1]
bearishEngulfing = close < open and close[1] > open[1] and close < low[1] and open > high[1]
// Buy and Sell Conditions
buySignal = trendUp_15min and bullishEngulfing
sellSignal = trendDown_15min and bearishEngulfing
// Auto Buy Entry
if (buySignal)
strategy.entry("Buy", strategy.long)
label.new(bar_index, low, "BUY", color=color.green, style=label.style_label_up, textcolor=color.white)
// Auto Buy Exit (1:3 RR)
if (strategy.position_size > 0)
stopLossBuy = swing_low
takeProfitBuy = close + (close - stopLossBuy) * 3
strategy.exit("Buy Exit", "Buy", stop=stopLossBuy, limit=takeProfitBuy)
// Auto Sell Entry
if (sellSignal)
strategy.entry("Sell", strategy.short)
label.new(bar_index, high, "SELL", color=color.red, style=label.style_label_down, textcolor=color.white)
// Auto Sell Exit (1:3 RR)
if (strategy.position_size < 0)
stopLossSell = swing_high
takeProfitSell = close - (stopLossSell - close) * 3
strategy.exit("Sell Exit", "Sell", stop=stopLossSell, limit=takeProfitSell)
// Plot Buy/Sell Signals with Shapes
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
strategy("5-Min Gold Scalping Strategy with 1:3 RR", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=2)
// Trend Direction (Using 15-Minute Price Action)
higherHigh = ta.highest(high, 5)
higherLow = ta.highest(low, 5)
lowerHigh = ta.lowest(high, 5)
lowerLow = ta.lowest(low, 5)
trendUp_15min = request.security(syminfo.tickerid, "15", higherHigh > higherHigh[1] and higherLow > higherLow[1])
trendDown_15min = request.security(syminfo.tickerid, "15", lowerHigh < lowerHigh[1] and lowerLow < lowerLow[1])
// Price Action on 5-Minute Chart
// Support/Resistance (Swing Lows/Highs)
swing_low = ta.lowest(low, 5)
swing_high = ta.highest(high, 5)
// Candlestick Patterns (Bullish/Bearish Engulfing)
bullishEngulfing = close > open and close[1] < open[1] and close > high[1] and open < low[1]
bearishEngulfing = close < open and close[1] > open[1] and close < low[1] and open > high[1]
// Buy and Sell Conditions
buySignal = trendUp_15min and bullishEngulfing
sellSignal = trendDown_15min and bearishEngulfing
// Auto Buy Entry
if (buySignal)
strategy.entry("Buy", strategy.long)
label.new(bar_index, low, "BUY", color=color.green, style=label.style_label_up, textcolor=color.white)
// Auto Buy Exit (1:3 RR)
if (strategy.position_size > 0)
stopLossBuy = swing_low
takeProfitBuy = close + (close - stopLossBuy) * 3
strategy.exit("Buy Exit", "Buy", stop=stopLossBuy, limit=takeProfitBuy)
// Auto Sell Entry
if (sellSignal)
strategy.entry("Sell", strategy.short)
label.new(bar_index, high, "SELL", color=color.red, style=label.style_label_down, textcolor=color.white)
// Auto Sell Exit (1:3 RR)
if (strategy.position_size < 0)
stopLossSell = swing_high
takeProfitSell = close - (stopLossSell - close) * 3
strategy.exit("Sell Exit", "Sell", stop=stopLossSell, limit=takeProfitSell)
// Plot Buy/Sell Signals with Shapes
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.