Example: How to make an mechanical system.

Discussion in 'Trading' started by danielc1, Jan 5, 2009.

  1. danielc1


    I have been around this site for a couple of years and I do not know realy why, but I would like to give a step by step instruction about building a ‘mechanical’ tradingsystem.
    I do many things in live, not knowing why so, here it goes:

    First of all some ‘rules’.
    I will answer questions but however I will not discuss endless point of views...
    Please do not PM with all sort of questions, I rarely open that, just use this treath. I would also like to tell you that English is not my natural language, thus be kind with my spelling.

    I would like to give a brief summary of what is coming:

    First I will make a trend following system and later on a non trend system.

    What are the things I need to build a trend system?:

    A filter to know what market condition I’m in.
    To me there are 9 different market conditions:

    high,low,midlle volatility and up,down,side ways marketdirections or any combinations of these two measerments.

    Now how do I measure volatility? Average True Range does the trick, but you could also use raw data like the difference between high and low on any given minute/ day/week/month and compare this with other periods…
    Lets keep it simple and use Average True Range to measure volatility.

    Second thing I need to know is the direction of the market: Is it up, down or sideways?

    You can use many things for this, you could use a counter to count new highs or lows, DMI indicator for direction and so on.
    Or even simple movingaverages.
    Lets use three simple moving averages to determine market direction. (200,50,20).
    When the 20 > 50 and 20 > 200 and 50 > 200, then I would clasify this as ‘uptrend’, when 20 < 50 and 20 < 200 < and 50 < 200 then I would clasify this as ‘downtrend’.
    Everything in between, is a no- no for the trendsystem.

    So far the marketfilter. You could also ad volume to measure liquidity of the underlying instrument to your marketfilter, but that depends on what you are going to trade.

    Now let’s talk about some other things we need:

    Entry signals
    Exit signals
    Monte carlo simulations to determine what we can expect from our system.

    Entry signals: There are many, many possibility’s for an entry signal. A good entry signal makes you profitable from the start. (Most of the time, anyway) Also it exist about two things: a setup and a trigger. The setup is used to make you ready and the trigger is to get you profitable from the start.
    For a trendfollowing system the most important thing is to set you up with a low risk entry. This can be a retracement in the trend(setup) and suddenly a movement with the trend(trigger). For this example I will use a three lower high for the setup and buystop of the priorer high for the trigger, when we are in an uptrend. In an downtrend it is the ‘mirror’ of these signals.
    This is just an example, you can use your own ideas for this. Note: Uptrends and downtrends are not the same, but for simplicity I’m going to say they are…


    Exitsignals in a trendsystem are different then in a nontrend system. The purpose of a trendsystem is to be in as long as the trend ‘exist’ and exit when this end without given to much profit away. To make it worthwhile to use a trend system, you must also have a low risk point in your system:
    First exit: Stoploss: This is to ‘protect’ your capital, lets say that you choose a point where you know you are wrong about your entry. In this example it could be the low of the prior bar when you had your entrytrigger.

    Second exit: In a trend system it is important to give the underlying some room to develop.
    Too ‘narrow’ you exit premature.
    Too ‘lose’ you let a lot of profit on the table. So find something that locks profit in at some point. The best exit is some form of trailing stop for a trend following system. This could be a 20 day low exit or somekind of ATR of the high, low or close. Lets use a 2 x ATR of the close in this example.

    I will stop here for a moment to see if someone have some questions.

    In the next part I will let you see the most important things, like moneymanagement, monte carlo simulations and portfoliomanagement…
  2. Thank you for posting, Daniel, and you are doing well in English. Do you have a particular trading time frame in mind, like intra-day or daily or swing trading?
  3. danielc1


    'Any' time frame can do... It depends if the underlying show trendiness behavior in the past on the specified time frame. The best way is to open a chart and 'see' how the underlying has behaved in the past when our trend condition has been met. There are some indicators you can use to determine trendiness like the ADX for example... Later on with the monte carlo system simulation, we can 'determine' what is normal behavior for our trend system. When we have abnormal behavior then we will know that the underlying has 'changed'. Alterning the time frame can be one of the solutions then...
  4. taowave


    Thanks Daniel...

    Looking foward to the thread

  5. danielc1


    Okay, lets go some what further. I would like a suggestion on a symbol for our example. A stock symbol or a future symbol...
  6. AAPL
  7. danielc1


    Aapl it is...
  8. danielc1


    Now because we have picked a stock, there are a few more things that you must consider before using a trend system in 'both' directions. A stock market can be in a bull market or bear market. If you are not a day trader, I would use a month graph of the stock plus a 9 period simple moving average on it. When it reads higher then the prior month, implement only long strategy's. If it reads lower then the prior month, only use short strategy's.

    If you are a intraday trader, you could also invent a filter to know that the daily bar is in a 'bull' mode or a 'bear' mode and only use the trend system accordingly intraday.

    Have put up a daily bar graph(Bear) and a intraday graph 5 minute of AAPL(Bull) with stops.(purple dots)
  9. danielc1


    5 min graph
  10. danielc1


    As you can see on the graph's, there are multiple 'entry' points during our condition of what a trend is... That is good. You need multiple 'entry' points in case you get stoped out.

    On a daily graph you have not yet a realy run up that makes everything all 'right'. The first trade in our example on the daily graph is at the end of october(3 higher lows with a trigger of the prior low) and you are stop out just after december 8 with a minor profit. The second entry is just the day after you are stopout and this trade is still going...

    On the intrayday chart you have an entry at 01/02/08 and around 11u20minutes. This trade is still going... But the stop that is locked in for now is 94,29.(If it not close and gaps against you the next day, you could asume you have a profit...)
    #10     Jan 5, 2009