Australian (ASX) Stock Market Forum

EOD trades with weekly ASX MA filter

Joined
11 January 2020
Posts
30
Reactions
48
Hi all.

I have code for a bbo style system that generates signals from end of day closing price. I have this 75 day MA index filter (not my own, I copied it from another thread) however I find that the daily MA is too active, and would prefer the index filter to only use the weekly closing price of the index for its moving average.

Is this possible, and does anyone have an example they would be happy to share?

IndexClose = Foreign("XAO", "C");
IndexMA = MA(IndexClose, 75);
GoLong = IndexClose > IndexMA;
 
Pretty certain it can, but you'll first need to use the TimeFrameSet prior to your IndexClose = line and then after your GoLong line use TimeFrameRestore so it reverts back to daily, which is what I think you want to do--use a weekly filter on daily charts.
 
Pretty certain it can, but you'll first need to use the TimeFrameSet prior to your IndexClose = line and then after your GoLong line use TimeFrameRestore so it reverts back to daily, which is what I think you want to do--use a weekly filter on daily charts.
Great! I'll give it a go. Thanks so much.
 
What about using daily MA on a longuer period .to do as requested use @MovingAverage solution but it could be simpler to just increase the MA period based on daily data?
I tried extending the daily MA, but when looking on a chart I was not able to get the same result as using a weekly close.
 
I tried extending the daily MA, but when looking on a chart I was not able to get the same result as using a weekly close.
I understand and yes will be different but would a moving average of weekly close be that better?
then why do you consider this better as a weekly close is just one close out of 5?
Anyway @MovingAverage's answer is the strictly right way to get what you want
 
It seems that the filter is probably using the current days data in the equation, thus showing up as too active.
By using a weekly figure, you are smoothing the data out over however many bars.
Maybe an average of the 2, with weightings considered, might smooth your data out to a more desirable level?
Cheers.
F.Rock
 
@wasp is this what you are looking for?

or maybe a starting point....let us know how you are going.

Code:
DailyIndex = Foreign("$XAO", "C");

TimeFrameSet( inWeekly );
IndexClose = Foreign("$XAO", "C");
IndexMA = MA(IndexClose, 75);
TimeFrameRestore();

WeeklyIndex = TimeFrameExpand(C, inWeekly,expandLast );

GoLong = WeeklyIndex > IndexMA;


SetChartOptions(0,chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | styleBar | GetPriceStyle() );

Plot( WeeklyIndex,"Weekly Index", colorYellow, styleLine  | styleOwnScale, Null, Null, 0, -1, 1);
Plot( DailyIndex,"Index", colorRed, styleLine | styleOwnScale, Null, Null, 0, -1, 1);
 
@wasp is this what you are looking for?

or maybe a starting point....let us know how you are going.

Code:
DailyIndex = Foreign("$XAO", "C");

TimeFrameSet( inWeekly );
IndexClose = Foreign("$XAO", "C");
IndexMA = MA(IndexClose, 75);
TimeFrameRestore();

WeeklyIndex = TimeFrameExpand(C, inWeekly,expandLast );

GoLong = WeeklyIndex > IndexMA;


SetChartOptions(0,chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | styleBar | GetPriceStyle() );

Plot( WeeklyIndex,"Weekly Index", colorYellow, styleLine  | styleOwnScale, Null, Null, 0, -1, 1);
Plot( DailyIndex,"Index", colorRed, styleLine | styleOwnScale, Null, Null, 0, -1, 1);

Good work Trav...I was too lazy to write the code for him :p
 
Top