- This topic has 4 replies, 4 voices, and was last updated 9 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › Standard Deviation from Moving Average
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.
Sure. Here’s a 20 period Standard Deviation of price from a 50 MA. Change the first 2 lines to adjust the lookback variables:
1 2 3 4 5 6 7 8 9 10 11 |
//Set lookbacks; #$MA = 50; #$SD = 20; //Calc MA; MA1 = MA(BARS=$MA, CALC=Close); //Calc % diff; DIFF = ((CLOSE() - MA1) / MA1)*100; //Std Dev of Diff; STD(DIFF, BARS=$SD) |
Here’s the value in a watchlist column and a Show View histogram:
Thank you, Darren!
This is great.
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
Hi,
Yes, this should be possible using the following adjusted script:
1 2 3 4 5 6 7 8 9 10 11 |
//Set lookbacks; #$MA = 50; $SD = BARCOUNT(Month(PERIODAMOUNT=1)); //Calc MA; MA1 = MA(BARS=$MA, CALC=Close); //Calc % diff; DIFF = ((CLOSE() - MA1) / MA1)*100; //Std Dev of Diff; STD(DIFF, BARS=$SD) |
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.
Cookie | Duration | Description |
---|---|---|
cname | 14 days | This cookie is set by Optuma. The cookies is used to store the users campaign selection for selecting the correct version of Optuma to trial and is "Necessary". |
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |