High Probability Trend Strategy

Discussion in 'Options' started by mario0887, Jun 20, 2019.

  1. panzerman

    panzerman

    For a tutorial on Kalman filtering have a look at this web site, and work through some of the examples. If you passed high school algebra, you should have no problem with the math.

    https://www.kalmanfilter.net/default.aspx

    Then for a bit more advanced viewpoint try reading this guys blog:

    http://dekalogblog.blogspot.com/2019/04/test-of-constant-velocity-model-kalman.html

    Kalman filters are actually more estimators than lowpass filters, but have similar design. Kalman filters are structured similar to IIR digital filters.
     
    #41     Jun 23, 2019
    varaamo likes this.
  2. panzerman

    panzerman

    Kalman filter algorithms can be written in any programming language. Search for John Ehlers Zero Lag (well almost). You will find his paper with simple code. This lowpass filter is about the best I have come across. I would describe it as a KALMANesq filter.
     
    #42     Jun 23, 2019
  3. ironchef

    ironchef

    Can I do it in Excel VBA?
     
    #43     Jun 24, 2019
  4. panzerman

    panzerman

    Sure, here is my code. If price is in column A, enter a starting number cell B1, and enter =Kalman() in cell B2. The function is called from an active cell, so you have to copy and paste the function in each cell in column B.

    Function kalman() As Double

    Static alpha As Double
    Dim leasterror As Long
    Dim i As Integer
    Dim ma As Double
    Dim gain As Double
    Dim best As Double
    Dim error As Double

    alpha = 0.07
    ma = alpha * Cells(ActiveCell.Row, ActiveCell.Column - 1).Value2 + (1 - alpha) * Cells(ActiveCell.Row - 1, ActiveCell.Column).Value2
    leasterror = 1000000
    For i = -50 To 50
    gain = i / 10
    kalman = alpha * (ma + gain * (Cells(ActiveCell.Row, ActiveCell.Column - 1).Value2 - Cells(ActiveCell.Row - 1, ActiveCell.Column).Value2)) + (1 - alpha) * Cells(ActiveCell.Row - 1, ActiveCell.Column).Value2
    error = Cells(ActiveCell.Row, ActiveCell.Column - 1).Value2 - kalman
    If Abs(error) < leasterror Then
    leasterror = Abs(error)
    best = gain
    End If
    Next i
    kalman = alpha * (ma + best * (Cells(ActiveCell.Row, ActiveCell.Column - 1).Value2 - Cells(ActiveCell.Row - 1, ActiveCell.Column).Value2)) + (1 - alpha) * Cells(ActiveCell.Row - 1, ActiveCell.Column).Value2

    End Function
     
    #44     Jun 24, 2019
    varaamo, Baozi and ironchef like this.
  5. Nice work!
    I'm thinking about how to modify the function to work in MS Access with a table of quotes ...
     
    #45     Jun 24, 2019
  6. ironchef

    ironchef

    Thanks, I appreciate the help.

    Regards,
     
    #46     Jun 25, 2019
  7. gliak

    gliak

    dear jeffalvisnon....everything comes with a price or a reason. Do not be so critical with newbies plus this is something you might find in a community like this....+ are you really the owner of the only holy grail of trading?
     
    #47     Jul 1, 2019
    BrooksRimes likes this.
  8. tomorton

    tomorton


    The 10,000 hours rule only applies to very narrow circumstances, and not to private retail trading as one example.

    As another example, who would possibly believe it takes 10,000 hours to learn to drive a car?
     
    #48     Jul 1, 2019
  9. My understanding is that Gladwell was not talking about 10,000 hours to be competent, as in driving a car, but in order to be expert, as in Mario Andretti.
     
    #49     Jul 1, 2019
  10. tomorton

    tomorton


    This is correct, but the rule has been abused by extending it to trading. Also learning a foreign language and heaven knows what else.

    I'd go so far as to suggest it would take 2 days to learn a simple profitable forex trading strategy, plus 1 day for familiarisation with the platform.
     
    #50     Jul 1, 2019