The Perfect Portfolio?

About the Author Jeff Swanson

Jeff is the founder of System Trader Success - a website and mission to empowering the retail trader with the proper knowledge and tools to become a profitable trader the world of quantitative/automated trading.

follow me on:
  • Rafael Haddock says:

    Having a problem downloadibg Perfect Portfilio files. Get message: “there nwas a problem sending the command to the program” I have TS 8.8

    Wouls appreciate any help. Thanks!

    • jeff says:

      The downloading should be fine. Can you try again? Or, are you having problems importing the Strategy and/or workspace into TradeStation?

  • Rafael Haddock says:

    Havingproblems importing strategy and workspace into Trade Station. Maybe a firewall or virus protectiob issue?

  • Rafael Haddock says:

    I got both files open. Sorry about the false cry for help. Thanks for all the work you do.

    • jeff says:

      Not a problem. Glad it’s working out for you and thanks for the kind words.

  • Rafael Haddock says:

    Jeff, two quick questions when you have a little hurry.

    1. I’m using the PRP to trade Futures( Russell, emini gold). Seems to work fine. You see ant reason not to?

    2. Your code provides for system to enter New Bear Market, but in practice it never does. Is there somethig in the code that needs to be changed so system goes short when market conditions indicate?



    • jeff says:


      1) It should trade fine on futures. The only slight problem would be when it prints the event log. Currently it reports all prices only to two decimals. Some futures contracts, such as EC, go well beyond that and it would not print correctly. However, I don’t see any reason why it would not trade just fine.

      2) Shorting is controlled within TradeStation. If you go under format->strategies you will see the ability to enable or disable short positions. The workspace provided has the short positions disabled. Just change that to allow shorting. If you have trouble finding it, let me know.

  • Rafael Haddock says:

    Followed your directions. Works great. Thanks!

  • Jeff S says:


    Hopefully it wouldn’t inconvenience you too much to attach the code in a .txt (zip). Am very interested, but because of serious security issues with downloads recently and with all the version changes (and OO coming) in TS, etc. have been forced to stop importing ELD’s Posting the code in text would also be helpful to those who might want to port it to other platforms, Many thanks.

    • jeff says:

      That is a good idea. I may have to add a text version to the site. Until then, I just sent you a text copy Jeff S.

  • Paul says:

    Really interesting post. Thanks for this. One question though, you say that ” the concept they are using is well known, simple and totally free”, but then the set-up you give requires a $99/mo platform service subscription. At that rate it would be much more cost effective to just go and sign-up for marketclub. Am I missing something here? Are there any open or free platforms to track this you would reccommend as an alternative?

    • jeff says:

      The concept that is free is called price channel breakout. You don’t need any software to execute these trades once you understand the underlining concept.

      The TradeStation platform fee is zero dollars if you make more than 10 round trips per month. I don’t pay a fee because I’m a day trader and easily qualify. But the Perfect R Portfolio will not generate nearly that many trades.

      In the simplest form you can simply determine entry levels and exit levels by looking at at a chart. As you know the entry/exit points are simply the highest high or lowest low of the past three weeks. Do this once a week on the weekend and place your orders at your brokerage account. This would get you the same results as with the EasyLanguage code. Also, with only four markets to watch it would not be too much work.

      With Yahoo Finance for End-of-Day historical data, which is free, you could also build an excel spreadsheet to help produce the trade signals as well.

      I don’t have much experience with other charting platforms or brokers, but I do know that Ninja Trader is free and you can import Yahoo Finance for End-of-Day historical data with it.

      Hope this helps.

  • Flires says:


    How exactly did you determine the position sizing using the Percent Risk Model in the modified R Portfolio example with a 2% risk per position? I was trying to manually compare the average position of the fixed percentage (25%) to the percent-based approach you suggested (2%). I’m not arguing the validity of the Percent Risk Model but I’m trying to make sure I understand it. To me risk-per-trade can be a number of things including amount invested per position and stop-loss stated as a percent.


    • Jeff says:

      The 2% Risk Model simply means I will risk no more than a maximum of 2% of my account on any given trade. For a $50,000 account you will risk no more than $1,000 per trade. For a given trade, the risk of the trade is determined from the entry point of a position minus the stop loss. For example, if this value is $5 (entry price minus stop price = $5) we would then determine we would purchase 200 shares ($1,000 / $5 risk per share). Does this help?

  • Flires says:

    Yes- thanks Jeff.

    It’s still amazing that you can outperform the 25% exposure in the initial model while risking so much less. I appreciate your response.


  • Windsurfer says:

    Thanks, Jeff.

    FYI, I ran it on commodity futures (HG, SI, KC). I had to change the percent risk to 10% to generate trades. @GC was the best, with a profit of $66k. Buy and hold would have been $80k. If the system went short as well, it would have lost $ overall. How much has the long only result been biased by the strong rise in the underlying?

    I am not surprised that ES was a losing system, but it was good to get confirmation of the conventional wisdom that equity futures stopped trending in 1987.


  • Mark says:

    Before I comment on ETF Replay, I see the dates of comments to this post are 2010-2011 and yet the original post has a date of 2013. What am I missing here? 🙂

    • This is due to the fact articles are updated with new information and “re-posted” to push them to the top of the chronological queue. Unfortunately, the dates on comments will looks strange. Suppressing the dates on comments might be a good solution.

  • Sean Green says:

    Hi Jeff
    Could you please tell me if there has been any updates on trading the perfect R portfolio, and its profitability?
    also, do you have any details on “price channel breakout” strategy.
    many thanks

    • I’ve not updated that article in a while. I’ll add that to my to-do list and try to update this article soon. Thanks!

  • May says:

    I use import data, however, the strategy cannot work.
    Can you help ?

    • It’s been a while since I looked at this article. So, it’s due for an update. For now, I would suggest you review the code and anywhere there is a division calculation, perform a check on the denominator before performing the division calculation. If there is a zero in a denominator you skip the division calculation and use zero as the result. Thus, you avoid the division by zero error. This is something I’ve missed in the original code, but it is a good practice to get into when writing software.

  • May says:

    I change the code as follows :

    If (TrendHigh + 0.5 ) = 0 then vShares = 100;

    If (TrendHigh + 0.5 0) then
    vShares = IntPortion( Equity*.25 / TrendHigh + 0.5 );

    However, the problem still exist. The open,high, low & close
    prices are same for my data file,will this be the issue not
    generate barnumber data required in the strategy ?

    No problem for tradestation symbol data

    • Think the code should read…

      If (TrendHigh + 0.5 ) = 0 then vShares = 100
      else vShares = IntPortion( Equity*.25 / TrendHigh + 0.5 );

  • May says:

    Should be :

    If (TrendHigh + 0.5 ) = 0 then vShares = 100;

    If (TrendHigh + 0.5 0) then
    vShares = IntPortion( Equity*.25 / TrendHigh + 0.5 );

  • anna sr says:

    Hi Jeff can you also please add daily signals thanks.It generate weekly and monthly signals, but not daily thanks.

    • Hello. I think this is functioning correctly as it’s weekly price levels which are used to place buy orders on the daily chart.

      • anna sr says:

        true but is it possible to add also daily price levels on daily charts like you have 3 types of signals thanks

  • >