0% found this document useful (0 votes)
296 views4 pages

SuperTrend 315 Trading Strategy

The document outlines the 'Enhanced SuperTrend 315 Strategy' for trading, utilizing indicators such as SuperTrend, EMA, RSI, and MACD. It includes input parameters for customization, entry conditions for long and short positions, and risk management strategies. Additionally, it features plotting of indicators and alert conditions for buy and sell signals.

Uploaded by

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

SuperTrend 315 Trading Strategy

The document outlines the 'Enhanced SuperTrend 315 Strategy' for trading, utilizing indicators such as SuperTrend, EMA, RSI, and MACD. It includes input parameters for customization, entry conditions for long and short positions, and risk management strategies. Additionally, it features plotting of indicators and alert conditions for buy and sell signals.

Uploaded by

Amlan Bhadra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//@version=5

strategy("Enhanced SuperTrend 315 Strategy", overlay=true,


margin_long=100, margin_short=100, pyramiding=1,
default_qty_type=strategy.percent_of_equity, default_qty_value=100,
commission_type=[Link], commission_value=0.05)

// Input Parameters

factor = [Link](2.5, "SuperTrend Factor", minval=1, maxval=5,


step=0.1)

atrPeriod = [Link](7, "ATR Period", minval=3, maxval=20)

emaShort = [Link](3, "Fast EMA", minval=2, maxval=10)

emaLong = [Link](9, "Slow EMA", minval=5, maxval=20)

rsiPeriod = [Link](14, "RSI Period", minval=7, maxval=21)

volPeriod = [Link](21, "Volume SMA Period", minval=10, maxval=50)

riskPct = [Link](2, "Risk %", minval=1, maxval=5, step=0.5)

maxLoss = [Link](5, "Max Loss %", minval=2, maxval=10, step=0.5)

// SuperTrend Calculation

atr = [Link](atrPeriod)

upperBand = (high + low)/2 + factor * atr

lowerBand = (high + low)/2 - factor * atr

var float superTrend = na

var float trend = na

var float prevUp = na

var float prevDn = na

prevUp := upperBand

prevDn := lowerBand
if close > prevUp[1]

superTrend := lowerBand

trend := 1

else if close < prevDn[1]

superTrend := upperBand

trend := -1

else

superTrend := superTrend[1]

trend := trend[1]

// Indicator Calculations

emaFast = [Link](close, emaShort)

emaSlowHigh = [Link](high, emaLong)

emaSlowLow = [Link](low, emaLong)

ema200 = [Link](close, 200)

rsi = [Link](close, rsiPeriod)

[macdLine, signalLine, _] = [Link](close, 12, 26, 9)

volSMA = [Link](volume, volPeriod)

// Entry Conditions

bullishCrossover = [Link](emaFast, emaSlowHigh)

bearishCrossover = [Link](emaFast, emaSlowLow)

validVolume = volume > volSma * 1.5

uptrend = trend == 1

downtrend = trend == -1

// Strategy Logic

longCondition = bullishCrossover and uptrend and

close > ema200 and


rsi > 45 and rsi < 70 and

validVolume and

macdLine > signalLine

shortCondition = bearishCrossover or downtrend or

close < ema200 or

rsi > 70

// Risk Management

trailOffset = factor * atr

var float stopPrice = na

if longCondition

[Link]("Long", [Link])

stopPrice := high - trailOffset

if strategy.position_size > 0

stopPrice := [Link](stopPrice, high - trailOffset)

[Link]("Exit", "Long", stop=stopPrice, loss=close * (1 -


maxLoss/100))

if shortCondition or time >= timestamp(year, month, dayofmonth, 15, 15)

[Link]("Long")

// Plotting

plot(superTrend, color=trend == 1 ? [Link] : [Link], linewidth=2,


title="SuperTrend")

plot(ema200, color=[Link], title="200 EMA")

plot(emaFast, color=[Link], title="Fast EMA")


// Alerts

alertcondition(longCondition, title="Buy Signal", message="Long Entry


Signal")

alertcondition(shortCondition, title="Sell Signal", message="Exit Position")

// Table Display

var table positionTable = [Link](position.bottom_right, 2, 2)

if [Link]

[Link](positionTable, 0, 0, "Current Trend", bgcolor=[Link])

[Link](positionTable, 1, 0, trend == 1 ? "Bullish" : "Bearish",

bgcolor=trend == 1 ? [Link] : [Link])

[Link](positionTable, 0, 1, "Next ATR", bgcolor=[Link])

[Link](positionTable, 1, 1, [Link](atr, "#.00"),


bgcolor=[Link])

You might also like