Hi,
First, I like the implementation. It is good. And you guys are GREAT!
But I think we are missing something.
I see a nice updating in the code based on user constants that set the 'error'.
But I think Kalman is more than updating. I love what you do. I am not trying to start a debate. I sure I would lose rather quickly!
But what I see is updating based on a set of constants applied to the distance (and velocity) from the past periods to the current period at close. Correct?
Kalman uses a 'prediction' for the current value, then compares that prediction to the actual value after close, to adapt the error factor in the formula? I don't see this happening or am I missing this?
In short, Kalman in TStation (a GOOD implementation!)
But I think is actually not maximising what Kalman does.
I think I see a real value for the current period being placed at close, when Kalman already has a number at OPEN for the current period and uses that. Then at close, it checks the 'error' in that estimate, then slowly adapts K or Shk to make better and better estimates for the current period. I think? And recurses forward (not backward like Hodrick-Prescott Filter) thus avoiding repainting troubles.
But the magnitude of the 'error' in any given period is mostly a function of the constants I put in and price movement and the constants that are entered never 'adapt' to real data.. ShK=math.sqrt(Sharpness*K/100) and these are constants. The only variable for error is 'Distance' and the last observation (I think I see below) but there is no 'adaptation' for the calculation of error based on previous errors...it is just a new value based on the most recent price move (and the constants applied to that).
local Error=KalmanFilter[period-1]+Distance*ShK;
Velocity[period]=Velocity[period-1]+Distance*K/100;
KalmanFilter[period]=Error+Velocity[period];
So the new KalmanFilter value is an update based on what happened, whereas and the 'predictive' loop that would inform the 'kalman error term' is missing in this implementation?
If I actually understand Kalman correctly, it is entirely possible that I do not undersand the TS code and for this I apologise for taking your time to even read this. You guys are GREAT! But are we not missing something?
Below is an excerpt on Kalman......................Thanks Patrick
But are we not missing the true 'adaptiveness' of Kalman?
The Kalman filter can be written as a single equation, however it is most often conceptualized as two distinct phases: "Predict" and "Update". The predict phase uses the state estimate from the previous timestep to produce an estimate of the state at the current timestep. This predicted state estimate is also known as the a priori state estimate because, although it is an estimate of the state at the current timestep, it does not include observation information from the current timestep. In the update phase, the current a priori prediction is combined with current observation information to refine the state estimate. This improved estimate is termed the a posteriori state estimate