Conversion of indicator: Kalman Filter from Tradingview

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #196839 quote
    Jiacky
    Participant
    Junior

    Indicator Kalman Filter. It allows efficiently smoothing the noise, extracting the main trend from it.

    Kalman Filter is a variety of recursive filters. To assess the system status as of the current operation tact, it needs a status assessment (as the system status assessment and the error assessment of defining this status) at the preceding operation tact, and measuring at the current tact. This property distinguishes it from packet filters requiring to know at the current operation tact the history of measurements and/or assessments.

    More about Kalman Filter.

    The indicator has three input parameters:

    • K – Kalman factor;
    • Sharpness – factor for calculating the error minimization;
    • Applied price – price used for calculations.

    Calculations:

    Kalman[i] = Error + Velocity[i]

    where:

    Error = Kalman[i-1] + Distance * ShK
    Velocity[i] = Velocity[i-1] + Distance * K / 100
    Distance = Price[i] - Kalman[i-1]
    ShK = sqrt(Sharpness * K / 100)
    
    Code:

    //@version=5
    indicator(‘Kalman Filter [Loxx]’, overlay = true, shorttitle=”KF [Loxx]”, timeframe=””, timeframe_gaps=true)

    src = input(ohlc4)
    Sharpness = input.float(1.0)
    K = input.float(1.0)

    greencolor = color.lime
    redcolor = color.red

    velocity = 0.0
    kfilt = 0.0

    Distance = src – nz(kfilt[1], src)
    Error = nz(kfilt[1], src) + Distance * math.sqrt(Sharpness*K/ 100)
    velocity := nz(velocity[1], 0) + Distance*K / 100
    kfilt := Error + velocity

    plot(kfilt, color=velocity > 0 ? greencolor : redcolor, linewidth = 2)

    #196841 quote
    Jiacky
    Participant
    Junior

    Screenshot:

    [attachment file=”196842″]

    #196844 quote
    Jiacky
    Participant
    Junior

    Code is attached. Thank you

    #196854 quote
    Nicolas
    Keymaster
    Master

    You can find 3 versions of the Kalman Filter in the code attached to this topic (huge indicator with 67 different type of moving averages):

    Indicateur AFR – Average Filter Regression

    #196913 quote
    Jiacky
    Participant
    Junior

    Thank you Nicolas.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Conversion of indicator: Kalman Filter from Tradingview


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Jiacky @jiacky Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Jiacky
3 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/06/2022
Status: Active
Attachments: 2 files
Logo Logo
Loading...