1+ // Test strategy for PineScript Optimizer validation
2+ // @param rsi_length:7-21-2 - RSI period length
3+ // @param rsi_overbought:70-90-5 - RSI overbought threshold
4+
5+ //@version=5
6+ strategy("Test Strategy", overlay=true)
7+
8+ // Input parameters
9+ rsi_length = 17, "RSI Length", minval=1, maxval=100)
10+ rsi_overbought = 80, "RSI Overbought", minval=50, maxval=100)
11+
12+ // Calculate RSI
13+ rsi_value = ta.rsi(close, rsi_length)
14+
15+ // Entry condition
16+ enterLong = rsi_value < 30
17+ enterShort = rsi_value > rsi_overbought
18+
19+ // Exit conditions
20+ exitLong = rsi_value > 70
21+ exitShort = rsi_value < 30
22+
23+ // Strategy logic
24+ if (enterLong)
25+ strategy.entry("Long", strategy.long)
26+ if (enterShort)
27+ strategy.entry("Short", strategy.short)
28+ if (exitLong)
29+ strategy.close("Long")
30+ if (exitShort)
31+ strategy.close("Short")
32+
33+ // Plot RSI
34+ plot(rsi_value, "RSI", color=color.blue)
35+ hline(30, "Oversold", color=color.green)
36+ hline(70, "Overbought", color=color.red)
37+ hline(rsi_overbought, "Custom Overbought", color=color.orange)
0 commit comments