OPEN-SOURCE SCRIPT

minne

//version=5
strategy("RSI Trading Bot", overlay=true)

// Input variables
rsiLength = input(14, "RSI Length")
oversold = input(20, "Oversold Level")
overbought = input(80, "Overbought Level")
lotSize = input.float(1, "Lot Size")
stopLossPips = input(500, "Stop Loss (Pips)")
takeProfitPips = input(500, "Take Profit (Pips)")

// Calculate RSI
rsi = ta.rsi(close, rsiLength)

// Convert pips to price points
pipValue = syminfo.mintick
stopLossPoints = stopLossPips * pipValue
takeProfitPoints = takeProfitPips * pipValue

// Buy Condition
longCondition = ta.crossover(rsi, oversold)
if longCondition
strategy.entry("Buy", strategy.long)
strategy.exit("TP/SL", from_entry="Buy", limit=close + takeProfitPoints, stop=close - stopLossPoints)

// Sell Condition
shortCondition = ta.crossunder(rsi, overbought)
if shortCondition
strategy.entry("Sell", strategy.short)
strategy.exit("TP/SL", from_entry="Sell", limit=close - takeProfitPoints, stop=close + stopLossPoints)

Clause de non-responsabilité