Cosine Kernel Regressions [QuantraSystems]

QuantraSystems Uppdaterad   
Cosine Kernel Regressions


The Cosine Kernel Regressions indicator (CKR) uses mathematical concepts to offer a unique approach to market analysis. This indicator employs Kernel Regressions using bespoke tunable Cosine functions in order to smoothly interpret a variety of market data, providing traders with incredibly clean insights into market trends.

The CKR is particularly useful for traders looking to understand underlying trends without the 'noise' typical in raw price movements. It can serve as a standalone trend analysis tool or be combined with other indicators for more robust trading strategies.


Fast Trend Signal Line - This is the foreground oscillator, it is colored upon the earliest confirmation of a change in trend direction.

Slow Trend Signal Line - This oscillator is calculated in a similar manner. However, it utilizes a lower frequency within the cosine tuning function, allowing it to capture longer and broader trends in one signal. This allows for tactical trading; the user can trade smaller moves without losing sight of the broader trend.

Case Study

In this case study, the CKR was used alongside the Triple Confirmation Kernel Regression Oscillator (KRO)

  • Initially, the KRO indicated an oversold condition, which could be interpreted as a signal to enter a long position in anticipation of a price rebound. However, the CKR’s fast trend signal line had not yet confirmed a positive trend direction - suggesting that entering a trade too early and without confirmation could be a mistake.

  • Waiting for a confirmed positive trend from the CKR proved beneficial for this trade. A few candles after the oversold signal, the CKR's fast trend signal line shifted upwards, indicating a strong upward momentum. This was the optimal entry point suggested by the CKR, occurring after the confirmation of the trend change, which significantly reduced the likelihood of entering during a false recovery or continuation of the downtrend.

  • This is one of the many uses of the CKR - by timing entries using the fast signal line, traders could avoid unnecessary losses by preventing premature entries.


The methodology behind CKR is a multi-layered approach and utilizes many ‘base’ indicators.
  • Relative Strength Index
  • Stochastic Oscillator
  • Bollinger Band Percent
  • Chande Momentum Oscillator
  • Commodity Channel Index
  • Fisher Transform
  • Volume Zone Oscillator

The calculated output from each indicator is standardized and scaled before being averaged. This prevents any single indicator from overpowering the resulting signal.

//  ╔════════════════════════════════╗  //
//  ║    Scaling/Range Adjustment    ║  //
//  ╚════════════════════════════════╝  //
RSI_ReScale   (_res      ) => (      _res - 50   ) * 2.8
STOCH_ReScale (_stoch    ) => (    _stoch - 50   ) * 2
BBPCT_ReScale (_bbpct    ) => (    _bbpct - 0.5  ) * 120        
CMO_ReScale   (_chandeMO ) => ( _chandeMO * 1.15 )
CCI_ReScale   (_cci      ) => (      _cci / 2    )
FISH_ReScale  (_fish1    ) => (    _fish1 * 30   )
VZO_ReScale   (_VP, _TV  ) => (_VP / _TV) * 110

These outputs are then fed into a customized cosine kernel regression function, which smooths the data, and combines all inputs into a single coherent output.
//              ╔════════════════════════════════╗              //
//              ║    COSINE KERNEL REGRESSIONS   ║              //
//              ╚════════════════════════════════╝              //
// Define a function to compute the cosine of an input scaled by a frequency tuner
cosine(x, z) =>
    // Where x = source input
    //       y = function output
    //       z = frequency tuner
    var y = 0.
    y := math.cos(z * x)
// Define a kernel that utilizes the cosine function
kernel(x, z) =>
    var y = 0.
    y := cosine(x, z)
    math.abs(x) <= math.pi/(2 * z) ? math.abs(y) : 0.    //    cos(zx) = 0
//  The above restricts the wave to positive values      //     when x = π / 2z

The tuning of the regression is adjustable, allowing users to fine-tune the sensitivity and responsiveness of the indicator to match specific trading strategies or market conditions. This robust methodology ensures that CKR provides a reliable and adaptable tool for market analysis.
Added combined alerts
Added multi-timeframe functionality.

No statements or claims aim to be financial advice,
neither are any signals from us or our indicators.

Want to learn Trading, Investing or system building?
Join the Community! 👇

Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?