卡尔曼PSaR结合了著名的抛物面SAR（PSaR）和卡尔曼滤波器的先进平滑功能。这一创新工具旨在通过集成卡尔曼滤波来增强传统的PSaR，从而降低噪声并改善趋势检测。卡尔曼PSaR动态适应价格变动，使其成为一个高度有效的指标，用于发现趋势变化，同时最大限度地减少市场波动引起的错误信号的影响。通达信函数包括了 抛物转向 SAR(N,S,M)其中N为计算周期，S为步长，M为极值。 请你首先描述一下不同N、S、M参数对指标的影响。第二点，下面是卡尔曼滤波PSaR的Python代码，请将其转化为通达信公式的代码：

// Indicator Calculation 
N_kRoc = 5
f_init(series float pricesource_kRoc) =>
    var float[] stateEstimate = array.new_float(N_kRoc, na)
    var float[] errorCovariance = array.new_float(N_kRoc, 100.0)
    if na(array.get(stateEstimate, 0))
        for i = 0 to N_kRoc-1
            array.set(stateEstimate, i, pricesource_kRoc)
            array.set(errorCovariance, i, 1.0)

    [stateEstimate, errorCovariance]

f_kalman(series float pricesource_kRoc, float []stateEstimate, float []errorCovariance, simple float processNoise_kRoc, simple float measurementNoise_kRoc) =>
    var float result = na

    // Prediction Step
    predictedStateEstimate = array.new_float(N_kRoc)
    predictedErrorCovariance = array.new_float(N_kRoc)
    for i = 0 to N_kRoc-1
        array.set(predictedStateEstimate, i, array.get(stateEstimate, i)) // Simplified prediction
        array.set(predictedErrorCovariance, i, array.get(errorCovariance, i) + processNoise_kRoc)
    
    kalmanGain = array.new_float(N_kRoc)
    for i = 0 to N_kRoc-1
        kg = array.get(predictedErrorCovariance, i) / (array.get(predictedErrorCovariance, i) + measurementNoise_kRoc)
        array.set(kalmanGain, i, kg)
        array.set(stateEstimate, i, array.get(predictedStateEstimate, i) + kg * (pricesource_kRoc - array.get(predictedStateEstimate, i)))
        array.set(errorCovariance, i, (1 - kg) * array.get(predictedErrorCovariance, i))
    
    result := array.get(stateEstimate, 0)
    result

kalman_PSaR(start, inc, max, simple float processNoise_kRoc, simple float measurementNoise_kRoc) => 

    [stateEstimate_close, errorCovarianc_close] = f_init(close)
    [stateEstimate_high, errorCovariance_high]  = f_init(high)
    [stateEstimate_low, errorCovariance_low]    = f_init(low)

    kalman_close = f_kalman(close, stateEstimate_close, errorCovarianc_close, processNoise_kRoc, measurementNoise_kRoc)
    kalman_high  = f_kalman(high , stateEstimate_high, errorCovariance_high, processNoise_kRoc, measurementNoise_kRoc )
    kalman_low   = f_kalman (low  , stateEstimate_low, errorCovariance_low, processNoise_kRoc, measurementNoise_kRoc  )

    // PSar calculation

    var float result = na
    var float maxMin = na
    var float acceleration = na
    var bool isBelow = na
    bool isFirstTrendBar = false
    
    if bar_index == 1
        if close > close[1]
            isBelow := true
            maxMin := kalman_high
            result := kalman_low[1]
        else
            isBelow := false
            maxMin := kalman_low
            result := kalman_high[1]
        isFirstTrendBar := true
        acceleration := start
    
    result := result + acceleration * (maxMin - result)
    
    if isBelow
        if result > low
            isFirstTrendBar := true
            isBelow := false
            result := math.max(kalman_high, maxMin)
            maxMin := kalman_low
            acceleration := start
    else
        if result < high
            isFirstTrendBar := true
            isBelow := true
            result := math.min(kalman_low, maxMin)
            maxMin := kalman_high
            acceleration := start
            
    if not isFirstTrendBar
        if isBelow
            if high > maxMin
                maxMin := kalman_high
                acceleration := math.min(acceleration + inc, max)
        else
            if kalman_low < maxMin
                maxMin := kalman_low
                acceleration := math.min(acceleration + inc, max)
    
    if isBelow
        result := math.min(result, kalman_low[1])
        if bar_index > 1
            result := math.min(result, kalman_low[2])
        
    else
        result := math.max(result, kalman_high[1])
        if bar_index > 1
            result := math.max(result, kalman_high[2])
    
    
    result


ma(src, len, type) =>
    switch type
        "SMA" => ta.sma(src, len)
        "Hull" => ta.hma(src, len)
        "Ema" => ta.ema(src, len)
        "Wma" => ta.wma(src, len)
        "Dema" => ta.dema(src, len)
        "RMA" => ta.rma(src, len)
        "LINREG"=> ta.linreg(src, len, 0)
        "TEMA" => ta.tema(src, len)

psar = kalman_PSaR(start, inc, max, processNoise_kRoc, measurementNoise_kRoc)