ExoScope Signal
ExoScope RSI Divergence
Pivot-based bullish/bearish RSI divergences — price makes a lower low while RSI makes a higher low (and the mirror for highs). Tunable pivot lookback and RSI period.
exoscopedivergencersireversal
Sign in to installPublished 5/20/2026
Source
35 lines · 1167 chars
const rsiLen = input('rsi_period', 14, { min: 2, max: 50 });
const pivotLen = input('pivot_lookback', 5, { min: 2, max: 20 });
const minGap = input('min_gap', 8, { min: 3, max: 30 });
const rsiVal = ta.rsi(close, rsiLen);
const pLow = ta.pivotLow(low, pivotLen, pivotLen);
const pHigh = ta.pivotHigh(high, pivotLen, pivotLen);
let lastLowBar = -1, lastLowPrice = 0, lastLowRSI = 0;
let lastHighBar = -1, lastHighPrice = 0, lastHighRSI = 0;
let lastSignal = -minGap;
for (let i = pivotLen; i < barCount - pivotLen; i++) {
if (i - lastSignal < minGap) continue;
if (pLow[i] !== null && rsiVal[i] !== null) {
if (lastLowBar >= 0 && low[i] < lastLowPrice && rsiVal[i] > lastLowRSI) {
signal(i, 'buy', low[i], 'Bull div');
lastSignal = i;
}
lastLowBar = i;
lastLowPrice = low[i];
lastLowRSI = rsiVal[i];
}
if (pHigh[i] !== null && rsiVal[i] !== null) {
if (lastHighBar >= 0 && high[i] > lastHighPrice && rsiVal[i] < lastHighRSI) {
signal(i, 'sell', high[i], 'Bear div');
lastSignal = i;
}
lastHighBar = i;
lastHighPrice = high[i];
lastHighRSI = rsiVal[i];
}
}
Code runs in a sandboxed Web Worker — no network or DOM access. Use at your own risk. Not financial advice.