Donchian breakout trading system example (4 week rule)

This topic contains 1 reply, has 2 voices, and was last updated by  jinlongren100 3 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #633
    Seer
    Seer
    Keymaster

    The 4 week rule was developed by Richard Donchian and has been proven to be an effective base for many profitable trading systems. The original rules were used for trading commodities but can be used for other asset classes such as forex and stocks, the rules can be summarized by:

    1. Cover short positions and buy long whenever the price exceeds the highs of the previous 4 calendar weeks
    2. Liquidate long positions and sell short whenever the price falls below the lows of the previous 4 calendar weeks

    As Seer is able to use multiple time frames the above rules would be expressed as:

      BuyOpen  if ClosePrice > Today(Highest(Weekly->High,4));
      SellOpen if ClosePrice < Today(Lowest(Weekly->Low,4));

    If run with a SAR (stop and reverse) money management strategy, the above system will always maintain a position in the market (either long or short).

    When the market is not trending the above system will produce lots of whipsaws which can drastically effect the performance of the system. A common solution to this problem is to enter on the 4 week rule (the breakout), and to exit on a shorter time frame such as 1 or 2 weeks. The following system implements this approach. The example also uses the more familiar use of 20 daily bars rather than 4 calendar weeks.

     

    #This system is based upon the 4 week rule by Richard Donchian
    
    #Rules:
    #Enter long when the close exceeds the high of the previous 20 bars
    #Exit long when the close falls below the low of the previous 10 bars
    #Enter short when close falls below the low of the previous 20 bars
    #Exit short when the close exceeds the high of the previous 10 bars
    
    unless (Position) {
      #we have no position, perform entry logic
      BuyOpen if ClosePrice>Yesterday(Highest(High,20));
      SellOpen if ClosePrice<Yesterday(Lowest(Low,20));
    }
    else {
      #We have a position
      if (LongPosition) {
        #We have a long Position, perform exit logic
        SellOpen if ClosePrice<Yesterday(Lowest(Low,10));
      }
      else {
        #We have a short Position, perform exit logic
        BuyOpen if ClosePrice>Yesterday(Highest(High,10));
      }
    }
    • This topic was modified 5 years, 11 months ago by  jez.
    • This topic was modified 5 years, 11 months ago by Seer Seer.
    • This topic was modified 5 years, 11 months ago by Seer Seer.
    • This topic was modified 5 years, 11 months ago by Seer Seer.
    • This topic was modified 5 years, 9 months ago by Seer Seer.
    • This topic was modified 5 years, 9 months ago by Seer Seer.
    #4778

    Again, where is the complete sample code for this strategy?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.