Skip to main content

Feature Engineering

Feature Engineering in the Lorentzian Classification indicator involves selecting, transforming, and curating meaningful data inputs before they feed into the machine learning model. Well-chosen features help the model recognize complex market patterns, reduce noise, and ultimately produce more robust trading signals. Conversely, poorly chosen or overly redundant features can lead to overfitting, slow computations, or misleading results.

Interactive Settings Explorer​

Below is an interactive exploration of the Feature Engineering interface. Click any setting to instantly view its detailed documentation, default value, and purpose:

Lorentzian Classification [2.06 - Beta]

🧠 FEATURE ENGINEERING

Setting Help

Select a setting to view its help information

Why Feature Engineering Matters​

Enhanced Predictive Power Financial data can be noisy and non-stationary. Meaningful transformations often reveal underlying signals the model might otherwise miss. For instance, using a short-period RSI plus a long-period RSI can help the model capture both short-term and longer-term momentum shifts.

Customized Analysis Your trading domain knowledge is invaluable. If you suspect that volume spikes matter more in certain regimes—or that mean reversion patterns are better detected by certain oscillators—feature engineering lets you align your inputs with your intuition.

Noise Reduction & Stability Smoothing raw data, filtering out outliers, or using rolling statistics can prevent the model from overreacting to random fluctuations. This is especially important when combining multiple indicators in PineScript.

Iterative Exploration There is rarely a “one-size-fits-all” feature set. The markets evolve, and so might your trading strategy. Feature engineering provides a flexible framework to adapt, add, or remove features as you gather new evidence or change market focus.

Multi-Method Strategies Combining diverse indicator types—momentum, trend, volatility, mean reversion—often leads to more robust modeling. For example, pairing RSI (momentum) with a WaveTrend oscillator (smoothed momentum) can give a balanced view of market oscillations.

Example Use Cases​

1. Dual-Length RSI for Multiple Market Regimes​

Scenario: You want one RSI tuned to short-term swings and another capturing broader trends. Implementation:

  • Enable “RSI” in two feature slots with different lengths (e.g., RSI(9) and RSI(14)).
  • Compare signals from short RSI to detect choppy market turnarounds, and longer RSI to capture more extended trends.

2. Momentum + Trend-Strength Combination​

Scenario: You suspect that a momentum oscillator (like WaveTrend) plus a trend-strength measure (like ADX) will identify stronger breakouts. Implementation:

  • Assign WaveTrend to Feature 1 and ADX to Feature 2 in the Lorentzian Classification UI.
  • Ensure both are normalized so that ADX’s higher scale doesn’t overshadow WaveTrend values.
  • Look for synergy: WaveTrend spotting momentum changes while ADX confirms if the move has real trend strength.

3. Mean Reversion + Volatility Filter​

Scenario: You primarily trade mean reversions but only when volatility is above a certain threshold. Implementation:

  • Use something like CCI or Bollinger-based data for your primary “mean reversion” feature.
  • Add a volatility measure (such as ATR or a custom-coded volatility indicator) to Feature 2.
  • Enable normalization for both features. If volatility is low, the model can down-rank those data points in neighbor matching.

4. Multi-Timeframe Signals​

Scenario: You scalp on a 5-minute chart but want confirmation from a daily trend. Implementation:

  • Load a daily ADX or daily RSI as a custom source in Feature 4 or 5.
  • Combine it with your intraday oscillator in Features 1–3.
  • Check if the higher-timeframe trend dimension helps filter out false positives on the lower timeframe.

5. Custom Oscillator + Doubling-Up for Emphasis​

Scenario: You have a proprietary oscillator that strongly correlates with your market, and you want it to weigh more heavily in the classification. Implementation:

  • Map the proprietary oscillator as a custom feature.
  • Add the same feature again (with identical parameters) in another feature slot to double its influence.
  • Confirm both features are normalized to ensure balanced impact among the rest of the indicators.

The Iterative Approach​

Start Small Begin with one or two well-known indicators (e.g., RSI, WaveTrend). Verify that the Lorentzian Classification indicator produces stable, interpretable signals.

Add Features Gradually Introduce a single new feature—like CCI, ADX, or a custom metric—at a time. Observe changes in the model’s on-chart signals and the “Trade Stats” section. Overhauling your feature set all at once makes it hard to pinpoint what’s helping or hurting.

Check Normalization If a newly added feature has a different range (for example, ADX can grow larger than RSI), make sure the “Normalization” option is enabled to avoid skewing the distance calculations. Otherwise, that feature might dominate or dilute the influence of other features.

Evaluate Correlations Export your feature data to CSV and analyze correlations in Python or any statistical tool. High correlation between features can be redundant. On the other hand, features with low correlation might add unique information.

Backtest & Forward Test Although Lorentzian Classification includes on-chart trade stats, it is not a substitute for a full TradingView backtest or a more advanced backtesting framework.

  • Use the Strategy Tester or a “Backtest Adapter” to get a realistic performance overview.
  • Look for consistent improvements in metrics you care about (e.g., fewer false signals, higher win rate, better risk-adjusted returns).

Document Everything Jot down which features and parameter settings you’ve tried—along with how the signals changed. Feature engineering is often trial-and-error. Keeping records prevents repeated mistakes and accelerates learning.

Key Settings & Tips​

Number of Features (Feature Count) Increasing the number of features (e.g., from 2 to 5 or more) can capture more complexity—but can also increase the risk of overfitting or PineScript timeouts. Many traders find a sweet spot around 5–8 features, but always test performance thoroughly.

Parameter A & Parameter B Many indicators have adjustable look-back periods or smoothing parameters. Small changes in these can drastically affect model predictions. For example, try RSI(14) vs. RSI(9) to capture different market regimes.

“Double-Up” for Weighting If you suspect one feature is more crucial than others, you can simulate giving it extra “weight” by using that feature multiple times with the same parameters. This approach can boost the feature’s influence in the distance calculation.

Normalization Checkboxes Each feature can be normalized by checking the relevant box in the UI. This ensures all features contribute on a level playing field. Not normalizing a large-range feature (e.g., ADX) can inadvertently dominate the model’s decisions.

Custom Features The indicator allows you to load external data streams or proprietary indicators. Make sure they produce valid floating-point values (not booleans or strings). If the external data is unbounded (like some volatility metrics), consider enabling normalization.

Performance & Timeouts If computations become slow or you get PineScript timeouts, try reducing the number of features or the maximum bars back. Another trick is downsampling: skipping bars or training on fewer historical bars to speed up calculations.

Pitfalls to Avoid​

Feature Overload More features do not always yield better results. Beyond a certain point, “curse of dimensionality” can degrade accuracy and slow performance. Keep your feature set purposeful.

Unbalanced Scales Failing to normalize can allow high-range indicators (like ADX or unbounded CCI) to overshadow others.

Redundant Indicators Two highly correlated indicators (e.g., RSI and Stoch RSI with the same length) might not add unique value.

Boolean or Categorical Series Lorentzian Classification typically assumes float inputs. Passing a series of 1 and 0 can distort distance calculations. If you must encode a boolean, consider converting it to a fraction or smoothed float.

Key Takeaways​

Align transforms with your hypothesis.
Track performance rigorously.
Refine continually.
Know when to stop.

Default: undefined
Purpose

Example Configurations​

High-Precision Trend Following Configuration:​

  • Number of Features: 5
  • Feature 1: RSI (Parameter A: 14, Parameter B: 1) - Reasoning: Standard RSI for momentum.
  • Feature 2: WT (Parameter A: 10, Parameter B: 11) - Reasoning: WaveTrend for smoothed momentum.
  • Feature 3: ADX (Parameter A: 20, Parameter B: 2) - Reasoning: ADX for trend strength confirmation.
  • Feature 4: CCI (Parameter A: 20, Parameter B: 1) - Reasoning: CCI for volatility-based momentum.
  • Feature 5: RSI (Parameter A: 9, Parameter B: 1) - Reasoning: Short-period RSI for capturing short-term swings, complementing longer-period RSI.
  • Normalization: Enabled for all features - Reasoning: Ensures balanced contribution from all features despite different scales. This configuration is designed for users who prioritize high-precision trend following. It combines a diverse set of momentum, trend strength, and volatility indicators to create a robust feature set. The dual RSI feature allows the model to capture both short-term and long-term momentum, while ADX and CCI add trend and volatility context. Normalization is crucial to ensure that all features contribute equally to the model's predictions, preventing any single indicator from dominating the analysis.

Custom Volume-Based Strategy Configuration:​

  • Number of Features: 3
  • Feature 1: Custom 1 (Volume Weighted MACD, Normalize: Enabled, Parameter A: 12, Parameter B: 26) - Reasoning: Volume-weighted MACD to capture momentum confirmed by volume.
  • Feature 2: Custom 2 (On Balance Volume, Normalize: Enabled, Parameter A: 14, Parameter B: 1) - Reasoning: On Balance Volume to measure buying and selling pressure.
  • Feature 3: ADX (Parameter A: 20, Parameter B: 2) - Reasoning: ADX for trend strength confirmation, ensuring volume breakouts are trend-supported.
  • All other features: Disabled - Reasoning: Focuses the model on volume and trend strength, avoiding dilution from other feature types. This configuration is tailored for users who believe volume is a critical factor in market movements. It integrates volume-based indicators with trend strength to identify volume-confirmed breakouts and avoid false signals. Volume Weighted MACD and On Balance Volume provide complementary perspectives on volume and momentum, while ADX ensures that trades are aligned with strong trends. Normalization is enabled for custom sources to balance their scale with ADX.

Low-Latency Scalping Configuration:​

  • Number of Features: 3
  • Feature 1: RSI (Parameter A: 7, Parameter B: 1) - Reasoning: Short-period RSI for quick momentum detection in scalping.
  • Feature 2: WT (Parameter A: 5, Parameter B: 5) - Reasoning: Short-period WaveTrend for fast, smoothed momentum signals.
  • Feature 3: CCI (Parameter A: 10, Parameter B: 1) - Reasoning: Short-period CCI for capturing short-term volatility swings.
  • Max Bars Back: 1500 - Reasoning: Reduces computational load and emphasizes recent price action relevant to scalping.
  • Normalization: Enabled for all features - Reasoning: Maintains balanced feature contribution despite different indicator scales. This configuration is optimized for scalping strategies that require low latency and quick responses. It uses shorter lookback periods for RSI, WT, and CCI to increase responsiveness to intraday price movements. Reducing 'Max Bars Back' further minimizes computational load, ensuring the indicator remains fast and reactive. Normalization is enabled to maintain balanced feature contribution. This setup prioritizes speed and responsiveness over long-term trend analysis, making it suitable for fast-paced intraday trading.