0% found this document useful (0 votes)
21 views1 page

File 3

Txt fx

Uploaded by

suhailmughanni
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)
21 views1 page

File 3

Txt fx

Uploaded by

suhailmughanni
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/ 1

//@version=5

strategy("Price Action Strategy", overlay=true)

// Input parameters
supportResistanceLength = input.int(10, title="Support/Resistance Length")
atrLength = input.int(14, title="ATR Length")
riskPercentage = input.float(1.0, title="Risk per Trade (%)", minval=0.1,
maxval=100)
stopLossATR = input.float(1.5, title="Stop Loss (ATR Multiplier)", minval=0.5,
maxval=5.0)
takeProfitATR = input.float(2.0, title="Take Profit (ATR Multiplier)", minval=1.0,
maxval=5.0)

// Calculate support and resistance


highestHigh = ta.highest(high, supportResistanceLength)
lowestLow = ta.lowest(low, supportResistanceLength)

// Plot support and resistance levels


plot(highestHigh, color=color.red, title="Resistance Level")
plot(lowestLow, color=color.green, title="Support Level")

// ATR for stop-loss and take-profit calculations


atr = ta.atr(atrLength)

// Candlestick patterns
isBullishPinBar = (close > open) and ((high - close) > 2 * (close - open)) and
((close - open) > (low - open))
isBearishPinBar = (open > close) and ((open - low) > 2 * (open - close)) and ((open
- close) > (close - high))
isBullishEngulfing = close > open[1] and open < close[1]
isBearishEngulfing = close < open[1] and open > close[1]

// Breakout signals
breakoutAboveResistance = ta.crossover(close, highestHigh)
breakoutBelowSupport = ta.crossunder(close, lowestLow)

// Buy and sell conditions


buySignal = (breakoutAboveResistance or isBullishPinBar or isBullishEngulfing)
sellSignal = (breakoutBelowSupport or isBearishPinBar or isBearishEngulfing)

// Execute trades
if (buySignal)
strategy.entry("Buy", strategy.long, comment="Buy Signal")
strategy.exit("Exit Buy", from_entry="Buy", stop=close - (stopLossATR * atr),
limit=close + (takeProfitATR * atr))

if (sellSignal)
strategy.entry("Sell", strategy.short, comment="Sell Signal")
strategy.exit("Exit Sell", from_entry="Sell", stop=close + (stopLossATR * atr),
limit=close - (takeProfitATR * atr))

// Plot buy/sell signals on the chart


plotshape(buySignal, style=shape.labelup, location=location.belowbar,
color=color.green, size=size.small, title="Buy Signal", text="BUY")
plotshape(sellSignal, style=shape.labeldown, location=location.abovebar,
color=color.red, size=size.small, title="Sell Signal", text="SELL")

You might also like