Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
243 views2 pages

Pine Script

The document is a TradingView Pine Script for the 'Smart Trade Pro Advanced' indicator, which uses Exponential Moving Averages (EMA) and the Relative Strength Index (RSI) to generate buy and sell signals. It includes customizable parameters for EMA lengths, RSI levels, stop loss, and target percentages, along with plotting features for signals and alerts. The script calculates stop loss and target prices based on the entry conditions and visually represents them on the chart.

Uploaded by

anandyuv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views2 pages

Pine Script

The document is a TradingView Pine Script for the 'Smart Trade Pro Advanced' indicator, which uses Exponential Moving Averages (EMA) and the Relative Strength Index (RSI) to generate buy and sell signals. It includes customizable parameters for EMA lengths, RSI levels, stop loss, and target percentages, along with plotting features for signals and alerts. The script calculates stop loss and target prices based on the entry conditions and visually represents them on the chart.

Uploaded by

anandyuv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=5

indicator("Smart Trade Pro Advanced", shorttitle="STPA", overlay=true)

// --- Inputs ---


fastEMALength = input.int(10, "Fast EMA Length", minval=1)
slowEMALength = input.int(20, "Slow EMA Length", minval=1)
rsiLength = input.int(14, "RSI Length", minval=1)
rsiOverbought = input.int(70, "RSI Overbought Level", minval=50, maxval=100)
rsiOversold = input.int(30, "RSI Oversold Level", minval=0, maxval=50)
slPercent = input.float(0.1, "Stop Loss %", minval=0.1, step=0.1)
targetPercent = input.float(0.3, "Target %", minval=0.1, step=0.1)

// --- EMA Calculation ---


fastEMA = ta.ema(close, fastEMALength)
slowEMA = ta.ema(close, slowEMALength)

// --- RSI Calculation for Confirmation ---


rsiValue = ta.rsi(close, rsiLength)

// --- Buy/Sell Signals with RSI Filter ---


buyCondition = ta.crossover(fastEMA, slowEMA) and rsiValue < rsiOverbought
sellCondition = ta.crossunder(fastEMA, slowEMA) and rsiValue > rsiOversold

// --- Stop Loss and Target Calculation ---


var float buySL = na
var float buyTarget = na
var float sellSL = na
var float sellTarget = na

if buyCondition
buySL := close * (1 - slPercent / 100)
buyTarget := close * (1 + targetPercent / 100)

if sellCondition
sellSL := close * (1 + slPercent / 100)
sellTarget := close * (1 - targetPercent / 100)

// --- Signal Persistence ---


var int trend = 0
if buyCondition
trend := 1
else if sellCondition
trend := -1
else
trend := 0

// --- Plotting Signals (Text Labels for Entry) ---


plotshape(buyCondition, style=shape.labelup, location=location.belowbar,
color=color.rgb(0, 255, 0), size=size.normal, text="Long", textcolor=color.white)
plotshape(sellCondition, style=shape.labeldown, location=location.abovebar,
color=color.rgb(255, 0, 0), size=size.normal, text="Short", textcolor=color.white)

// --- Plotting Stop Loss and Target Lines ---


plot(trend == 1 ? buySL : na, "Buy SL", color=color.red, style=plot.style_cross)
plot(trend == 1 ? buyTarget : na, "Buy Target", color=color.green,
style=plot.style_cross)
plot(trend == -1 ? sellSL : na, "Sell SL", color=color.red, style=plot.style_cross)
plot(trend == -1 ? sellTarget : na, "Sell Target", color=color.green,
style=plot.style_cross)

// --- Adding Text Labels for SL and Target using label.new() ---
if buyCondition
label.new(bar_index, buySL, "Stoploss", color=color.red, textcolor=color.white,
style=label.style_label_up, size=size.tiny)
label.new(bar_index, buyTarget, "Target", color=color.green,
textcolor=color.white, style=label.style_label_down, size=size.tiny)

if sellCondition
label.new(bar_index, sellSL, "Stoploss", color=color.red,
textcolor=color.white, style=label.style_label_down, size=size.tiny)
label.new(bar_index, sellTarget, "Target", color=color.green,
textcolor=color.white, style=label.style_label_up, size=size.tiny)

// --- Alerts ---


alertcondition(buyCondition, "Smart Trade Long Entry", "Smart Trade Long Entry with
SL and Target")
alertcondition(sellCondition, "Smart Trade Short Entry", "Smart Trade Short Entry
with SL and Target")

You might also like