Hello,
I'm trying to create a 3 Quarter Moving Average that recognizes March, June, September, and December as the quarters. What I am currently seeing is that the program assumes the latest trading day is the end of the latest quarter.
As way of an example, the current 3 quarter moving average should be computed using Dec '19, Mar '20 and June '20 month end close prices. But its currently using Mar'20, June '20 and 14-Sep-2020 prices.
Thanks
Size:
Color:
Hi,
Here's how you can code it:
CODE:
Please log in to see this code.
Note the use of undocumented call (2nd line) to scale the MA to Quarterly scale.
Size:
Color:
Thanks, I'll try that.
Size:
Color:
Hi Eugene,
I'm still getting the same results i.e. ma_q for the latest trading date is being computed using the latest trading price. My expectation will be that latest ma_q only changes every quarter, but it changes everyday.
Using the example for FTSE100 in the attached screenshot, you can see the ma_q changing from the 14-Sep to 15-Sep; when it should be 7042.8901 - ma_q as at last quarter ending 30-June-2020.
Size:
Color:
Hi Babatunde,
JPG is truly suboptimal for screenshots, PNG is a better choice:
JPEG or PNG – Which Image Format Offers Better Quality?Now on to your question. If current bar doesn't represent an end of quarter you can simply ignore the change, right?
CODE:
Please log in to see this code.
Size:
Color:
Still getting the same result i.e. quarterly ma is changing.
Re "...If current bar doesn't represent an end of quarter you can simply ignore the change, right?", not possible I am using the quarterly ma as the basis of structural momentum measure. see code below.
CODE:
Please log in to see this code.
Size:
Color:
Look, I wasn't staing that the MA won't change. It doesn't matter if it does. You should simply make your trading system ignore the change on the last bar if it's still the same Quarter of the year. And that's what the code in my post #5 is intended to show.
Size:
Color:
Thanks
Size:
Color:
Any time.
Size:
Color: