Pine Script Examples

Ready-to-use Pine Script strategies that work with HyperSync's webhook format.

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

  1. Add the Pine Script to your TradingView chart

  2. Click Alert (bell icon)

  3. Set Condition to your strategy name

  4. Set Action to "alert() function calls only"

  5. Enable Webhook URL and paste your HyperSync URL

  6. The message will be automatically populated from the alert() calls in your script

  7. Click Create

Important Notes

  • Replace YOUR_TOKEN with your actual HyperSync webhook token

  • Use alert.freq_once_per_bar_close to avoid duplicate signals within the same candle

  • The confidence field lets HyperSync filter signals — set higher for stronger signals

  • Test on TradingView's paper trading mode first before connecting to HyperSync

Last updated