Trading System: How to Refer to Previous Signals For MAup Trading System

Line1Beginners Course  |  Intermediate Course  |  Amibroker Course

When creating a trading system, sometimes we might want to refer to a previous bar or signal.  We could then compare it to today’s signal as part of our entry or exit criteria.

Using the “Ref” function in Amibroker is an easy way to compare previous signals, no matter what indicator or Array you are using.

This video also shows us a trading system that uses the Ref function to determine if today’s Moving Average is higher or lower than the same Moving Average from 25 days ago – in other words if it is pointing upwards or downwards.

Check out the video below!

The Results:

The results of the moving average pointing up trading system:

  • On an ASX 200 list over 13 years:
  • Win Percent: 40%
  • Average Annual Return: 33% p.a.
  • Maximum System Drawdown: 54%
  • Adding an XAO Index Filter of 125 day moving average:
  • Win Percent: 44%
  • Average Annual Return: 38% p.a.
  • Maximum System Drawdown: 40%

Using the same system on the Top 100, the results drop dramatically as we lose the benefit of small cap shares making outsized gains.  The average annual return becomes 17%, but the maximum draw down also drops to 31%.  The win percentage stays around the same, at 45%.

Obviously, these are just ideas that you can use for your own trading systems – they are not complete trading systems themselves.  It is wise to test this trading system yourself, add parts or modify to suit your own needs, being aware of your maximum drawdown pain threshold and understand the need to test on out-of-sample data.

But it is a great look at another trading system, how to use the “Ref” function to refer to previous bars or signals, and how to code them in Amibroker!

Like this post?  Leave a comment in the section below.

Happy Trending,

Dave McLachlan

Beginners Course  |  Intermediate Course  |  Amibroker Course Home

Videos in the FREE Amibroker Course:

  1. Amibroker: How To Import A Watchlist With A CSV File
  2. Amibroker: How To Backtest A Single Stock Or Index
  3. Amibroker: How To Backtest a Portfolio or Group of Stocks
  4. Amibroker: How To Optimize A Trading System
  5. Amibroker: How To Scan The Market For Buy And Sell Signals
  6. Amibroker: How To Use Explore To Find And Filter Stocks
  7. Amibroker: How To Add Position Sizing Using AFL
  8. Amibroker: How to Add An Index Filter To Your Trading System Using AFL
  9. Amibroker: How To Plot Your Trading System On A Chart (incl. Buy/Sell Arrows)
  10. Amibroker: How to Use the If, Then Else Function (IIF)
  11. Amibroker: How to Code the ATR Trailing Stop (Chandelier) using ApplyStop
  12. Amibroker: How to Plot ApplyStop on a Chart
  13. Amibroker: How to Code Van Tharp Position Sizing (Fixed Fractional)
  14. Amibroker: How to “Scale In” to Positions (1) – Buying Once a Month
  15. Amibroker: How to “Scale In” to Positions (2) – Pyramiding Three Times
  16. Amibroker: How to Use “Cross”, When One Thing Crosses Another
  17. Amibroker Advanced: How to Compare Equity Curves

FREE Trading System Video Lessons:

  1. 7 Free Trading Systems and Their Returns From The Last 13 Years
  2. Seven Full Trading Systems Revisited, With Completely New Data
  3. Trading System: How to Create A Buy and Hold Trading System
  4. Trading System: How to Code “Sell In May And Go Away”
  5. Trading System: How to Code a Moving Average Channel That Made 23% p.a
  6. Trading System: How to Code Highest Highs As Used In 52 Week Highs Or Turtle Trading System
  7. Trading System: How to Code a Bollinger Band Breakout Trading System
  8. Trading System: How to Code a Moving Average Crossover That Returned 28% per annum
  9. Trading System: How to Refer to Previous Signals For MAup Trading System
  10. Trading System: How to Code the Leap Of Faith (Gaps) Trading System That Returned 24% p.a.
  11. Trading System: How to Code a Short Selling System (Plus Results)
  12. Trading System: Meb Faber Trading System Using Different Timeframes
  13. Trading System: How to Code the Three Billion Dollar Trading System

FREE Amibroker Q & A Videos:

template=ol

Read Related Articles:




  And, subscribe for free to stay in touch and receive the latest updates:

Enter Your Email Address:

.
(Check Your Junk Mail, Just In Case)

August 11, 2013  Tags: , , , , , ,   Posted in: Amibroker Trading System, Articles On Building Wealth, Trading System

7 Responses

  1. Jeroen - August 24, 2014

    Great! Thanks so much, your videos are simple and very helpful. Best AFL education I can find. I really enjoy your cheery presentation style!
    Jeroen
    Netherlands

  2. Dave McLachlan - August 30, 2014

    Thanks so much Jeroen! Glad to help.

    Cheers – Dave

  3. Jon Frank - September 30, 2014

    Nice series of videos ! Just the right level of coding for those of us starting out.

    Quick question – is there a way of coding this ( or other systems ) whereby you try to put in a quasi hedge each time the system trades ie Every time it buys $10,000 of a US Stock, it automatically sells $10,000 of S&P futures ?

  4. Dave McLachlan - December 10, 2014

    Hey Jon,
    I’m almost certain you could do something like that. Surely an iif() statement could do it, between your buy and sell. And provided you set your position sizing to accept at least two trades at the same time. Beyond that, you’re on your own unfortunately 🙂
    Cheers, Dave

  5. sahen - October 8, 2014

    Hello
    These lessons are very useful
    Thank you
    But I tried to do like I could not
    How can I lay it down on my program … Is it found in the file?
    Active searched for AFL I did not find
    I repeat my thanks to you

  6. sahen - October 10, 2014

    Hello Mr.Dave
    Can I get a file that contains AFL Created by you?
    Thank you

  7. PHAT - December 6, 2014

    Hello
    You’re great. These lessons are very useful for me and my friends
    Thanks you very much.

Leave a Reply