OPEN-SOURCE SCRIPT

CryptoThunder Storm v1.21

48
CryptoThunder Storm v1.21 — Strategy (non-repainting, HTF-aware)

CryptoThunder Storm is a Pine v6 strategy that trades the cross of two moving-average variants computed on an alternate (higher) timeframe derived from your current chart. It’s built to be non-repainting by evaluating signals only at HTF bar boundaries and by avoiding lookahead. The script can trade LONG, SHORT, BOTH, or be disabled, and it includes a one-click invert Long/Short mode.

How it works

Two MA streams (Open/Close series).
You can choose from multiple MA types (SMA/EMA/DEMA/TEMA/WMA/VWMA/SMMA/Hull/LSMA/ALMA/SSMA/TMA). The script computes:

closeSeries – MA of the (possibly delayed) close

openSeries – MA of the (possibly delayed) open

Alternate Resolution (HTF).
The inputs allow you to multiply your current chart’s timeframe (e.g., on 5m with multiplier 3 → HTF = 15m). Both series are requested via request.security() with lookahead_off.

Non-repainting gating.
Signals are evaluated once per HTF bar (htfClosed gate). This ensures entries/alerts are aligned with HTF boundaries and prevents forward-shifting.

Entry logic.

Long when closeSeriesAlt crosses above openSeriesAlt.

Short when closeSeriesAlt crosses below openSeriesAlt.

Invert mode swaps these actions (a former long signal opens a short, and vice versa).
Orders are processed on bar close (process_orders_on_close=true).

Risk management (optional).
Optional initial TP/SL exits via strategy.exit() (ticks/points). Set 0 to disable.

Visuals.
The script colors bars (optional) and plots the two HTF series with a filled band, plus compact UP/DN/CL markers that match the executed side after inversion/filtering.

Inputs & configuration

Use Alternate Resolution?
Turns the HTF logic on/off. When off, the strategy uses the chart timeframe.

Multiplier for Alternate Resolution
Multiplies the current timeframe to form the HTF (e.g., 3×).

MA Type / Period / Offsets

MA Type — choose from 12 variants.

MA Period — core length.

Offset for LSMA / Sigma for ALMA — MA-specific tuning.

Offset for ALMA — center of mass for ALMA.

Delay Open/Close MA — shifts the source back by n bars for a more conservative (non-peek) calculation. Keep at 0 unless you know you want extra delay.

Show coloured Bars to indicate Trend?
Colors bars relative to HTF band.

What trades should be taken: LONG / SHORT / BOTH / NONE
Filters which sides are actually traded.

Invert Long/Short logic?
Swaps long ↔ short everywhere (orders, markers, JSON alerts).

Backtest window (Number of Bars for Back Testing)
Crude limiter to speed up testing. 0 = test full history.

TP/SL (Initial Stop Loss / Target Profit Points)
Values in ticks/points. 0 disables. They apply to both sides via strategy.exit().

Alert options

Turn on alerts (JSON)

Show alert marks (UP/DOWN/CLOSE)

Send CLOSE alerts (toggle)

The strategy fires alert() internally. Create an alert on “Any alert() function call”.
The payload is a simple JSON string:{ "text":"C98USDT.P UP"}

Messages:

UP — a long entry was executed (or, with Invert on: the inverted long signal that opens a long).

DOWN — a short entry executed.

CLOSE — position closed or flipped.

Tip: If you want to route long/short to different webhooks, parse the text field for UP, DOWN, or CLOSE

Plotting & markers

Band: Fills between the two HTF MA lines.

Bar color (optional): Quick visual trend cue.

Markers:

▲ “UP” below bar when a long executes.

▼ “DN” above bar when a short executes.

✖ “CL” on position close/flip.
These reflect the final executed side, after trade filters and after Invert mode

Best practices & notes

Non-repainting design.

request.security(..., lookahead_off) prevents future data leakage.

Signals are gated to HTF bar boundaries, so you won’t get intra-HTF recalculations.

Strategy orders are processed at bar close.

Choosing the multiplier.
A 2×–4× multiplier often balances responsiveness vs stability (e.g., 5m→15m or 20m). Larger multipliers reduce churn and false signals.

TP/SL units.
Values are in ticks/points of the chart symbol. On crypto, check your instrument’s tick size and adjust accordingly.

Trade filters apply after inversion.
With invertLS = true and tradeType = LONG, only final longs (post-inversion) are allowed.

Strategy vs chart counts.
The Tester reports closed trades; your chart shows entries/markers including the latest open trade. This can explain 8 vs 12 discrepancies over short windows.

Performance.
calc_on_every_tick=false and the backtest limiter keep the script responsive on long histories.

Tips: user on mid-volume crypto pair, 1M chart, best MA is: SMMA, Hull, SSMA, DEMA, TEMA.

This strategy is for research and education. Markets carry risk; past performance doesn’t guarantee future results. Always forward-test on paper and validate your exchange execution, tick size, and fees before deploying live.


Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.