Multi-Timeframe RSI-ROC Strategy Engine — Locked Specification

StockSeva Pro · Bank Nifty / Nifty 50 tactical entry engine · parameters finalized

1. Fractional RSI calculation

Wilder's smoothing (modified moving average) extended to fractional periods, with n = 3.5 and smoothing constant α = 1 / n ≈ 0.285714.

avg_gain_t = alpha * gain_t + (1 - alpha) * avg_gain_{t-1}
avg_loss_t = alpha * loss_t + (1 - alpha) * avg_loss_{t-1}
RS  = avg_gain_t / avg_loss_t
RSI = 100 - (100 / (1 + RS))

Seeding uses the standard Wilder seed — a simple average of gains and losses over the first ceil(n) bars — before switching to the recursive form. float64 is maintained throughout; intermediate RSI values are never rounded before feeding the ROC stage.

2. RSI rate-of-change (momentum acceleration)

3-candle lookback, matched to the RSI-3.5 fast trigger.

ΔRSI_3 = RSI_t - RSI_{t-3}

Absolute ΔRSI₃ is the decision variable. The percentage ROC variant is still computed and plotted for comparison. The same 3-bar lookback carries over to the higher-timeframe rising filter, keeping the logic consistent across timeframes.

3. Price structure pivot confirmation

3-bar pivot high/low, one bar on each side minimum, confirmed on bar close.

Pivot High at t:  High_t > High_{t-1} and High_t > High_{t+1}
Pivot Low  at t:   Low_t  < Low_{t-1}  and Low_t  < Low_{t+1}

Pivot sequence yields HH / HL / LH / LL, which feeds the entry gate as a boolean per bar. 3-bar is the sole confirmed configuration: 2-bar is too noisy, 5-bar lags on 15m.

4. Execution gap rule (Section 15)

If the entry candle's open gaps beyond the maximum allowable stop-loss percentage, the trade is aborted in full — no lot-size reduction fallback.

if abs(open_price - signal_close) / signal_close > max_allowed_gap_pct:
    trade_status = "ABORTED_GAP_RULE"
    skip_entry()
else:
    proceed_to_entry()

Every aborted trade is logged with signal timestamp, expected entry, actual open and gap %, and surfaced in the backtest's abort log and clustering charts.

5. Consolidated parameter table

Fast RSI period3.5
Fast RSI smoothing α1 / 3.5 (≈0.2857)
HTF confirmation RSI period14
ROC lookback (intraday)3-candle absolute ΔRSI
HTF rising filter lookback3-day
Pivot bar width3-bar
Gap rule behaviorAbort trade (no size reduction)

6. Exit rules — outside the locked spec

The specification defines the entry gate and abort rule but not exit logic. The backtest therefore uses a configurable stop/target model, defaulting to 0.5% stop, 2R target and a 12-bar time exit. Adjust these in the parameter panel once exit rules are finalized.