Standard Deviation from Moving Average

Optuma Forums Optuma Scripting Standard Deviation from Moving Average

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #66399
    Matthew
    • Topics: 15
    • Replies: 6
    • Posts: 21

    Is there a way to calculate the standard deviation price is from a stated moving average like the 50DMA?
    Is it possible to create a script for that?
    Thank you very much for your help.

    #66401
    Darren
    • Topics: 67
    • Replies: 705
    • Posts: 772

    Sure. Here’s a 20 period Standard Deviation of price from a 50 MA. Change the first 2 lines to adjust the lookback variables:

    Here’s the value in a watchlist column and a Show View histogram:

    Capture

    1 user thanked author for this post.
    #66403
    Matthew
    • Topics: 15
    • Replies: 6
    • Posts: 21

    Thank you, Darren!
    This is great.

    #66419
    Thomas
    • Topics: 110
    • Replies: 140
    • Posts: 250

    Hi,

    I want add to this forum thread and want ask the following question:

    Is it possible to use as the time period to calculate the STD a start date e.g. 01/01/1950 and not the fixed time period of e.g. 20 bars?

    Lets say I have a csv file with monthly data and the calculation for the STD should always start at 01/01/1950 and should include all monthly data from 01/01/1950 to the last date in the monthly csv file. This means the length for the calculation of the STD becomes one month/one time unit more every month. So the length of the calculation of the STD varies.

    Thanks,
    Thomas

    #66433
    Matthew
    • Topics: 5
    • Replies: 487
    • Posts: 492

    Hi,

    Yes, this should be possible using the following adjusted script:

    This script adjusts the $SD line to use a Monthly Bar Count total. As the monthly bar count changes, so will the STD Bar lookback period.

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

Pin It on Pinterest