Optuma Forums › Optuma Scripting › Standard Deviation from Moving Average › Reply To: Standard Deviation from Moving Average
November 1, 2021 at 9:31 am
#66433
- Topics: 5
- Replies: 616
- Posts: 621
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.