Trading system template

Home » Trading » Trading system template

We use multiple trading systems to actively trade on exchanges, some manually and some fully automated. You can now download the trading system template, to help you get started with building your trading system the right way.

You download the template straightaway by clicking on ‘add to cart’ button below:

or

Let’s start with some basic’s about trading systems. When someone says ‘trading system’, everyone starts thinking of intelligent ways of deriving BUY and SELL signals that generate profits. The reality of the situation is that a trading strategy contributes approximately 30% towards your profit the remaining 70% of contribution comes from the infrastructure/framework that surrounds the trading strategy. If you do not have the right infrastructure and/or framework around your trading strategy then you are bound to fail, guaranteed.

The infrastructure/framework consists of:

  1. Backtest : Have you setup your backtesting environment correctly? If your backtesting setup is erroneous then most likely the backtest results are erroneous leading you to pick a trading strategy that was never meant to work in the first place.
  2. Universe of tickers : Have you honed in on a pool of stocks/tickers that are relevant to the your trading style/strategy? If your universe of stocks are wrong, then even the best trading strategy will deliver mediocre results.
  3. Trades : Is your signal generation correct? Have you made any catastrophic mistakes like referencing future bars? Most traders make silly mistakes here costing them money in the long run.
  4. Risk management : Have you got all the risk management measures in place? A trader is a guaranteed to fail if they do not have appropriate risk management measures in place.
  5. Visualisation : Is your trading strategy doing exactly what it you think it is supposed to be doing? Visualising how/when/where your trading strategy picks trades could help you refine and identify exploitable edges.

We have done the work in building this infrastructure to help us experiment, test and execute various trading strategies correctly. We also use this same infrastructure to help us perform automated trading (i.e. without manual intervention). The process pipeline is set in an order that an algorithmic trading system is supposed to be setup. The trading strategy we have used here is quite simple. The strategy is based on cross between a Fast-exponentialMA and a Slow-exponentialMA. You will need to find your own trading strategy and implement that code in the appropriate section within this template. You can chop and change any part of the code as per your needs and fancies. However, the overall framework needs to remain the same in order to make sure you are running the backtests correctly and testing your trading strategies the right way. 

We use Amibroker as our analysis tool and code in AFL scripting language. This template is built for Amibroker analysis tool however the basics of framework are universal and can be ported over to your tool of choice.

NOTE: PLEASE BE AWARE THAT THIS IS A TEMPLATE FOR A TRADING SYSTEM AND NOT A TURNKEY TRADING SYSTEM.

The template includes following sections, in the order they appear:

<< BACKTEST >>
     1. Backtest settings – Important to setup these settings in order to have a legitimate backtest.
<< STOCKS UNIVERSE >>
     2. Reduce universe – Reduce amount of ticker you will be exploring to trade.   
     3. Index scanner – Use technical analysis on market indexes to determine whether you want to trade or not.
     4. Filters – Further determine which tickers are worth exploring for a buy or a sell signal.
<< TRADES >>
     5. Signal generation – Generate buy or sell signals using indicators.
     6. Collate signals – Collate the buy and sell signals to determine your plausible trades.
<< RISK MANAGEMENT >>
     7. Position sizing – Use dynamic position sizing to determine the size of a position.
     8. Position score – Use logic to rank the trades so that you only take the top-ranked trades in a day.
     9. Stop loss – Set stop-loss to make sure there is a catch-all if market turns sour out of the blue.
<< VISUALISE >>
     10. Display signals – use this AFL to also plot on a chart.
     11. Add columns – Use this AFL to also add columns to explorations.
<< END >>

Folder structure: Organising files and folders are an important part of software architecture. Therefore, even this template needs to be stored in the right folder/s for future reference and updates. The folder structure is provided below, please save files as shown in their respective folders:

FileFolder
tradingSystem-template.AFL Amibroker/Formulas/Systems
backtestSettings-template.AFL   Amibroker/Formulas/Include
windowMinMax.afl Amibroker/Formulas/Include
Folder structure for Amibroker Trading System AFL templates

Note: Our data provider is Norgate Data and some functions such as ‘GetFnData’ are specific to Norgate Data.

Usage:
To BackTest or Explore : Open a new/blank Analysis in Amibroker, pick “tradingSystem-template.afl” as your trading system file. Click either Backtest or Explore
To Visualise chart : Open a new/blank chart, open “tradingSystem-template.afl” in Amibroker editor. Click “Apply” from the menu options.

Please download the template by clicking on the ‘add to cart’ button below:

or

Author: The Portfolio Trader
Web: https://www.theportfoliotrader.com
Email: info@theportfoliotrader.com

If you find any bugs or would like to suggest improvements to this code then please email us on info @ theportfoliotrader.com. If you need help coding your own trading system or implementing your trading strategy, please free to email us on info @ theportfoliotrader.com

NOTE: PLEASE BE AWARE THAT THIS IS A TEMPLATE FOR A TRADING SYSTEM AND NOT A TURNKEY TRADING SYSTEM. 

By downloading this template you acknowledge that you have read and understood Risk Disclosures and Terms & Conditions

THE AUTHOR/S AND THE COPYRIGHT HOLDER/S EXPLICITY DENY PERMISSION TO ADVISORS, HEDGE FUNDS, HEDGE FUND MANAGERS, INSTITUTIONAL TRADERS, PROPRIETARY TRADING DESKS, FUND MANAGERS, SUBSCRIPTION SERVICE PROVIDERS AND ANY OTHER COMMERCIAL CONCERNS TO USE THIS TEMPLATE. INFRINGEMENTS TO THIS CLAUSE WILL BE DEALT ACCORDING TO THE COPYRIGHT INFRINGEMENT LAWS AS PER JURISDICTIONS OF THE UNITED STATES OF AMERICA AND THE AUSTRALIAN COMMONWEALTH.

All rights reserved. No part of this publication and template may be reproduced, distributed, or transmitted in any form or by any means, including online forums, email attachments, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.


Copyrights (C) The Portfolio Trader 

Leave a comment

Risk Disclosure | Terms & Conditions | Privacy Policy