Reference
Best Practices & Limitations
Build smaller, causal, validated, reproducible models that respect Pine Script’s execution model and communicate uncertainty honestly.
Updated Publisher Alien_AlgorithmsPine Script v6
Start small
- Begin with 4–8 hidden units and batches of 8–16.
- Prove that a dense baseline has signal before adding temporal or attention blocks.
- Add one architecture change at a time and compare validation behavior.
- Prefer stable feature definitions over a large feature count.
Protect causality
- Create features only from information available at their anchor bar.
- Delay target creation until the forecast horizon has resolved.
- Avoid centered indicators, negative offsets, or future-dependent normalization.
- Keep rolling windows chronological and align target offsets explicitly.
A model can learn leakage extremely well
Excellent historical accuracy is often the first symptom of contaminated data. Audit time alignment before tuning architecture.Validate honestly
- Use chronological holdouts rather than random shuffling.
- Fit scalers from training rows only.
- Track validation loss and a task-relevant metric.
- Compare with naive baselines such as last value, zero return, or majority class.
- Use early stopping when holdout behavior stops improving.
Budget Pine runtime
Control chart history
Set calc_bars_count to a deliberate value. History length, dataset capacity, sequence length, batch size, hidden width, and training frequency multiply one another.
Gate expensive work
Use .withTrainingGate(true) for heavy models. If you need history-wide adaptation, combine .trainEveryCall() with confirmed-bar, stride, and recent-window conditions.
Keep advanced blocks compact
Use short sequences, low filter/unit counts, and few attention heads. Pine Script is a chart runtime, not a GPU environment.
Reproducibility
- Seed weight initialization with
nl.rng(seed). - Keep feature ordering and hyperparameters explicit.
- Use deterministic replay seeds.
- Record the chart history window used for training.
- Export weights when a stable research snapshot matters.
Limitations
- Execution is bounded: models must remain compact enough for TradingView limits.
- History is contextual: bounded training windows can produce different state when reloaded later.
- Hyperparameter changes rebuild state: a changed script input can restart learning.
- Distribution shifts happen: validation on one regime does not guarantee another.
- Outputs are research signals: NeuraLib does not model your risk, execution, or financial objectives automatically.
What NeuraLib guarantees
NeuraLib provides model mechanics, shape checks, chronological data tools, and differentiable training infrastructure. It does not guarantee predictive edge, signal accuracy, or financial gain.