• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

EOD trades with weekly ASX MA filter

Discussion in 'Trading Strategies/Systems' started by wasp, Feb 1, 2020.

  1. wasp

    wasp

    Posts:
    4
    Likes Received:
    2
    Joined:
    Jan 11, 2020
    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;
     
    aus_trader likes this.
  2. MovingAverage

    MovingAverage Smoke me a kipper

    Posts:
    296
    Likes Received:
    403
    Joined:
    Jan 23, 2010
    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.
     
    wasp, barney and qldfrog like this.
  3. wasp

    wasp

    Posts:
    4
    Likes Received:
    2
    Joined:
    Jan 11, 2020
    Great! I'll give it a go. Thanks so much.
     
  4. qldfrog

    qldfrog

    Posts:
    4,226
    Likes Received:
    2,711
    Joined:
    Jun 8, 2008
    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?
     
    wasp likes this.
  5. wasp

    wasp

    Posts:
    4
    Likes Received:
    2
    Joined:
    Jan 11, 2020
    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.
     
  6. qldfrog

    qldfrog

    Posts:
    4,226
    Likes Received:
    2,711
    Joined:
    Jun 8, 2008
    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
     
    wasp and barney like this.
  7. frugal.rock

    frugal.rock "Time weight's on man"

    Posts:
    582
    Likes Received:
    637
    Joined:
    May 3, 2019
    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, fergee and qldfrog like this.
  8. Trav.

    Trav.

    Posts:
    643
    Likes Received:
    735
    Joined:
    Nov 27, 2017
    @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);
     
    aus_trader, wasp, qldfrog and 5 others like this.
  9. MovingAverage

    MovingAverage Smoke me a kipper

    Posts:
    296
    Likes Received:
    403
    Joined:
    Jan 23, 2010
    Good work Trav...I was too lazy to write the code for him :p
     
    wasp, frugal.rock and Trav. like this.
  10. frugal.rock

    frugal.rock "Time weight's on man"

    Posts:
    582
    Likes Received:
    637
    Joined:
    May 3, 2019
    I was too lazy to learn the code, let alone write it ...
    Onya Trav.
    F.Rock
     
    wasp, Trav. and MovingAverage like this.
  11. qldfrog

    qldfrog

    Posts:
    4,226
    Likes Received:
    2,711
    Joined:
    Jun 8, 2008
    MA(IndexClose, 75);
    on a weekly system.isn't 75 a bit high:1.5year???
     
    wasp likes this.
  12. Trav.

    Trav.

    Posts:
    643
    Likes Received:
    735
    Joined:
    Nov 27, 2017
    The period is up to Wasp to set and play with. I am sure that the optimise function will be used and a best fit will be found.
     
    wasp and qldfrog like this.
  13. wasp

    wasp

    Posts:
    4
    Likes Received:
    2
    Joined:
    Jan 11, 2020
    Thanks everyone for your replies, much appreciated.
     
    qldfrog likes this.
Loading...

Share This Page