File 3
File 3
// 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)
// 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)
// 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))