0% found this document useful (0 votes)
133 views

TRADING STRATEGY

This document outlines an optimized price action trading strategy using Pine Script version 6 for TradingView. It includes input parameters for risk management, technical indicators like EMA and ATR, and conditions for entering long and short trades based on price action patterns and volume analysis. The strategy also incorporates visual signals for trade entries and exits, along with risk management features such as stop loss and take profit levels.

Uploaded by

Abhishek Jain
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)
133 views

TRADING STRATEGY

This document outlines an optimized price action trading strategy using Pine Script version 6 for TradingView. It includes input parameters for risk management, technical indicators like EMA and ATR, and conditions for entering long and short trades based on price action patterns and volume analysis. The strategy also incorporates visual signals for trade entries and exits, along with risk management features such as stop loss and take profit levels.

Uploaded by

Abhishek Jain
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/ 3

//@version=6

strategy("Optimized Price Action Strategy with Debug", overlay=true,


default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// 🔹 Input Parameters
riskPerTrade = input.float(1.0, "Risk Per Trade (%)", minval=0.1, maxval=5.0,
step=0.1)
useEma = input.bool(true, "Use EMA Filter")
emaLength = input.int(20, "EMA Length", minval=5, maxval=200)
atrLength = input.int(14, "ATR Length", minval=1)
volumeMultiplier = input.float(1.5, "Volume Multiplier", minval=1.0, maxval=3.0,
step=0.1)
takeProfitR = input.float(2.0, "Take Profit (× Risk)", minval=0.5,
maxval=10.0, step=0.5)
atrMultiplier = input.float(1.0, "ATR Stop Loss Buffer", minval=0.1, maxval=2.0,
step=0.1)
useHigherTimeframe = input.bool(true, "Use Higher Timeframe EMA")
higherTimeframe = input.timeframe("D", "Higher Timeframe")

// 🔹 Technical Indicators
ema = ta.ema(close, emaLength)
atr = ta.atr(atrLength)
htfEma = request.security(syminfo.tickerid, higherTimeframe, ta.ema(close,
emaLength))

// 🔹 Volume Analysis
avgVolume = ta.sma(volume, 20)
highVolume = volume > (avgVolume * volumeMultiplier)

// 🔹 Price Action Patterns


bullishEngulfing = (
close > open and
close > close[1] and
open < open[1] and
(close - open) > (open[1] - close[1])
)

bearishEngulfing = (
close < open and
close < close[1] and
open > open[1] and
(open - close) > (close[1] - open[1])
)

bullishPinBar = (
low < low[1] and
close > open and
(close - open) / (high - low) > 0.6
)

bearishPinBar = (
high > high[1] and
close < open and
(open - close) / (high - low) > 0.6
)

// 🔹 RSI Divergence
rsi = ta.rsi(close, 14)
bullishDivergence = (low < low[2]) and (rsi > rsi[2])
bearishDivergence = (high > high[2]) and (rsi < rsi[2])

// 🔹 Entry Conditions
longCondition = (
((useHigherTimeframe and close > htfEma) or
(not useHigherTimeframe and close > ema)) and
(bullishEngulfing or bullishPinBar) and
highVolume and
bullishDivergence
)

shortCondition = (
((useHigherTimeframe and close < htfEma) or
(not useHigherTimeframe and close < ema)) and
(bearishEngulfing or bearishPinBar) and
highVolume and
bearishDivergence
)

// 🔹 Risk Management and Execution


if longCondition
stopLoss = low - (atr * atrMultiplier)
riskAmount = close - stopLoss
takeProfit = close + (riskAmount * takeProfitR)

strategy.entry("Long", strategy.long)
strategy.exit("Take Profit", from_entry="Long", limit=takeProfit,
stop=stopLoss)

label.new(
bar_index, low, "LONG\nSL: " + str.tostring(stopLoss) + "\nTP: " +
str.tostring(takeProfit),
color=color.green, textcolor=color.white, style=label.style_label_down,
size=size.small
)

if shortCondition
stopLoss = high + (atr * atrMultiplier)
riskAmount = stopLoss - close
takeProfit = close - (riskAmount * takeProfitR)

strategy.entry("Short", strategy.short)
strategy.exit("Take Profit", from_entry="Short", limit=takeProfit,
stop=stopLoss)

label.new(
bar_index, high, "SHORT\nSL: " + str.tostring(stopLoss) + "\nTP: " +
str.tostring(takeProfit),
color=color.red, textcolor=color.white, style=label.style_label_up,
size=size.small
)

// 🔹 Visual Signals
plot(ema, "EMA", color=color.blue)
plot(useHigherTimeframe ? htfEma : na, "HTF EMA", color=color.yellow)
plotshape(
series=longCondition, location=location.belowbar,
color=color.green, style=shape.triangleup, size=size.small, title="Long Signal"
)
plotshape(
series=shortCondition, location=location.abovebar,
color=color.red, style=shape.triangledown, size=size.small, title="Short
Signal"
)

You might also like