Pine Script Examples
Example 1: RSI Mean Reversion
//@version=5
strategy("HyperSync RSI Strategy", overlay=true)
// Parameters
rsiLength = input.int(14, "RSI Length")
oversold = input.int(30, "Oversold Level")
overbought = input.int(70, "Overbought Level")
// Calculate RSI
rsiValue = ta.rsi(close, rsiLength)
// Entry conditions
longCondition = ta.crossunder(rsiValue, oversold)
shortCondition = ta.crossover(rsiValue, overbought)
// Exit conditions
closeLongCondition = ta.crossover(rsiValue, overbought)
closeShortCondition = ta.crossunder(rsiValue, oversold)
if (longCondition)
strategy.entry("Long", strategy.long)
alert('{"symbol": "' + syminfo.ticker + '", "action": "buy", "price": ' + str.tostring(close) + ', "strategy": "RSI Mean Reversion", "confidence": 0.8, "secret": "YOUR_TOKEN"}', alert.freq_once_per_bar_close)
if (shortCondition)
strategy.entry("Short", strategy.short)
alert('{"symbol": "' + syminfo.ticker + '", "action": "sell", "price": ' + str.tostring(close) + ', "strategy": "RSI Mean Reversion", "confidence": 0.8, "secret": "YOUR_TOKEN"}', alert.freq_once_per_bar_close)
if (closeLongCondition)
strategy.close("Long")
alert('{"symbol": "' + syminfo.ticker + '", "action": "close", "price": ' + str.tostring(close) + ', "strategy": "RSI Mean Reversion", "secret": "YOUR_TOKEN"}', alert.freq_once_per_bar_close)Example 2: MACD Crossover
Example 3: Bollinger Band Breakout
Example 4: Multi-Indicator Confluence
Setting Up Alerts from Pine Scripts
Important Notes
Last updated
