My Buy and Sell Rules


Budonk started a post asking about the best Sell Rules. I have wanted to summarize my buy and sell rules so here goes.

My basic logic is to maximize Annual Return. For me the power of compounding has to dominate my approach. Giving up a few % Annual Return for a reduced drawdown becomes a big loss (lack of gain) over a 10 year period. I put little actual concern on drawdown. However, it is difficult to achieve a consistent annual gain if the approach continues to have high drawdowns. So my lower drawdowns that I achieve are not a goal, but a byproduct of chasing consistent annual return.

When I say I try to maximize my annual return, I am not speaking about the Annual Return on the Summery page. What I am referring to is maximizing the daily return of each stock that I buy. If I am willing to risk cash to buy a stock then it needs to meet the highest standards that I can find. For this I use the factor Gain/Stk/Day or the average gain on each stock I buy for each day that I hold the stock. To calculate this factor go to the Statistics; Trading page and divide the Average Return for the Realized Trades by the Average Days Held. This gives you a value of the % gain per stock traded per day that they were held. Or what I call the Gain/Stock/Day. If I can optimize this one parameter then I have optimized my annual gain relative to my risk of buying stocks in the first place.

Although I don’t try to time the market, I set up my Buy Rules such that if the market is in a decline the Sim will find very few stocks to buy. To do this I use restrictive Buy Rules. I limit the stocks I buy to those that will have the highest probability of good gains in the shortest period of time.

I use the Buy and Sell Rules below in almost all of my Ports. I use additional Rules in most of my Ports that are tied to the Ranking System’s approach.

Rank > 99
Since the highest ranked stocks, on average, out perform lower ranked stocks, why settle for stocks that, on average, will have lower performance. I’ll use Rank > 98 occasionally if it improves the Gain/Stock/Day. If there are not any stocks that meet this criterion and the other buy rules then I will either stay in cash or use the cash in another Port that finds stocks that meet all of its rules. I will not reduce the rank value just to find a stock to buy.

Price > 1
Lower priced stocks, on average, out perform higher priced stocks. So why would I want to restrict my buys from some of the best returns with a Price > 5 rule. However, Penny stock’s prices are all over the place and are very difficult to pick winners consistently.

MktCap > xx & MktCap < xxx
Smaller Cap stocks, on average, out perform larger Cap stocks. There are very few billion dollar companies that can double in price in a few months. However, in any giver year there are dozens of small and Micro Cap stocks that do it. I use; MktCap > 50 & MktCap < 500, for most of my ports, and MktCap > 100 & MktCap < 1000 for a few Ports that still show high performance with the higher Mkt Cap maximum.

AvgDailyTot(20) > xxxxxx
Set the min value for the smallest range that you can buy with the dollar amount that you need to spend on each stock. I need to buy a minimum of $10,000 per stock so I set it at 10 times that; AvgDailyTot(20) > 100000. Although this level, only 10 times what I am buying, will effect the buy and sell price somewhat, I find that overall I do better than if I only bought stocks that had an AvgDailyTot(20) > 200000, or 300000.

Pr4W%ChgInd > 0
This is a very restrictive rule. If the industry that a stock is in has not increased in value over the last 4 weeks I don’t want to buy it. This rule is very helpful during market corrections because it only allows the Port to buy stocks in industries that are not correcting. This rule, combined with the ones above, will frequently, during market corrections, prevent the Port from remaining fully invested. However, it improves my % winners by avoiding stocks in losing industries. This is my way of timing the market automatically. In my most aggressive Ports I will use; Pr4W%ChgInd > 5.

The Sell Rules I use are complementary to the buy rules and my desire to maximize my Gain/Stk/Day.

Rank < 99
If I don’t want to buy a stock that has a lower probability of gain why should I keep a stock that has a lower probability of gain, especially a stock that has declined in rank.
With some of my Ports I will use a Sell Rank value that is 1 less than the Buy Rank value if it improves the Gain/Stk/Day.

PctFromHi < -xx
I use a trailing % stop loss with all my real trades. I lost way too much money many years ago in Micro Caps that tanked after bad news. If you are going to trade Micro Caps I feel that a stop loss on your real trades is mandatory. Therefore, I use a stop loss Sell Rule in all my Ports. With the proper stop loss value you can normally increase Gain/Stk/Day and reduce the drawdown. I will use 20% in most of my Ports, 15% on the ports that trade the largest cap stocks, and 30 % on the Ports that trade the smallest of the Micro Caps.

GainPct < BenchPct & NoDays > 30
I use a Laggard rule in most of my Ports. 60 to 70 % of the highest Ranked stocks will outperform the Benchmark. Since the Benchmark performance is the average of the stocks that it benchmarks, and I am trying to maximize my annual performance, why would I keep a stock that can’t even do as well as the Benchmark? Sell it and buy another one. I have a 60 to 70 % chance of the next stock I buy out performing the Benchmark.

Pr4W%Chg /20 < 0.x & NoDays > 20
This is an aggressive sell rule. It requires a stock to maintain a minimum consistent gain over a rolling 4 week period. This will cause the port to sell a stock if it doesn’t meet a minimum performance criterion that the rest of the stocks in the Sim meet. I base the number I use for the x in the rule above on the Sim’s Gain/Stock/Day. This will be a number between 0.1 and 0.5 (hopefully), the higher the better. If the number is 0.2 I will generally use about 0.1 for the x in the sell rule above. In other words if a stock can’t do at least as well as ½ the average gain then I sell it and try another one.

This approach results in a higher turnover than most investors think is acceptable. However, it only takes me about 2 hours a week on Saturday or Sunday night to Rebalance my 10 Ports, review the stocks, and set up my trades. I trade on average 4 stocks a week out of 25 to 30 stocks total. I execute the trades first thing Monday morning.

The above buy and Sell Rules are based on my logic for the best way to achieve the highest Gain/Stock/Day. This approach is what results in my high returns in the P123 Weekly Performance email.

Good Trading,
Denny :sunglasses:


Thanks for sharing! This will no doubt help many of us improve our systems.

I will add a couple:

For a buy rule, I like to use Inst%Own<30. Using this insures that there is still plenty of room for institutional accumulation.

For a sell rule, sometimes I add a profit target of GainPct>NoDays+25. I won’t use this always - only when it improves the overall annual return. Using this will usually increase the % of winners, but may cut too many big winners short.


The attached spreadsheeet is a list of buy and sell rules that I refer to when I am creating new ports. I have not used most of these in my live ports, but maybe some of you will find them useful. One thing I have noticed is that port with complex buy and sell rules dont tend to do as well in real time as they do in the backtests. I’m sure this is do to the curveftting that comes into play when ‘tweaking’ these rules.

Master list of P123 buy and sell rules.xls (23.5 KB)

You guys are a great asset to the p123 community. Thanks again

1 Like

Thanks Dennis for your inputs.

Regarding your Pr4W%ChgInd > 0 buy rule, I strongly believe that we could improove our return if we had an option to use a little technical analysis on the industry groups.
If we had moving averages to play with or just the MACD (which is a EMA play) we could use as a buy rule that the industry group should be trending higher, eg a MACD>0 requirement or if you want a sligtly longer term approach EMA20>EMA50.
I reckon that this approach would be more effective than a simple 4 week return > 0.
What is your take on this?

Indeed an interesting thread.

I learn a new thing each time these guys start discussing.

A question:

A while back Denny’s Small Cap 98/98/20 w/ Gain/Stk/Day
portfolio tested best but going forward Denny’s Small Cap 96/96/20 or Vladinvest’s Port AAA outperformed it significantly. Were there any clues or rules of thumb that would have led one to believe that the latter protfolio would outperform the former one? I guess the less rules or the less complex as Dan says the higher the likelihood that a sim isn’t overoptimized is one rule of thumb (seems to be the case for neural network tests too). Any others?

Denny, I do find great value in your Gain/Stk/Day concept as a test statistic measurement but from my experience so far as illustrated in the previous example, sell rules based on it haven’t tested or turned out very well. Is it a rule where you think sims understate its effectiveness but works better in real life? I noticed for IReturn it had a tendency of getting out of a stock just before the stock started moving up sharply. Increasing the NoDays variable helped with the sim results at the time but I was wondering if that conflicted with the underlying logic of the rule which would seem to be to not give stocks breathing room but demand they start moving NOW.

While I’m at it, may I also ask you Denny what the significance is of those letters and numbers that sometimes accompany the names of of your sims and ports e.g. “a2b9s13_M1”? If it’s proprietary or an internal categorization system I understand if you’d rather refrain from commenting but if it’s something you’re willing to shed light on please do. It’s one of those little mysteries that I find nagging at the back of my mind like how do they get the caramel inside those chocolate bars? :slight_smile:

Thanks again all for the insight.


I use the Inst%Own<30 Buy Rule (or Inst%Own<40) in 3 of the 10 Ports that I am trading.
I ran some testing a while back to determine what range of stock Mkt Cap this would help on. What I found, in general, is for the smallest Micro Caps, less than about 100Mil, it doesn’t have much effect. I assume that is because there are few institutions interested in companies this small, and therefore, almost all of them have less than 30% institutional ownership. Also, above about 1Bil Mkt Cap there are few companies that don’t have greater than 30% institutional ownership, and using this rule results in fewer and fewer of the larger companies passinf this filter. So this Buy Rule seems to help the most with stocks with Mkt Cap between about 100Mil and 1Bil with fewer and fewer companies passing this filter as Mkt Cap gets larger.

I haven’t tried your GainPct>NoDays+25 Rule. It looks interesting. I’ll play with it some. It looks like it would go along with the approach that after a stock has made a good run its rate of increase slows down and a correction becomes more likely. If you can set the parameters right, on average, this might get you out before the correction.


An excellent set of rules and well organized! There are many rules in this list that I haven’t tried yet.


Technical analysis on the industry groups should improve our tools. I suggest that you make it a Feature Request.


My Port, Denny’s Small Cap 98/98/20 w/ Gain/Stk/Day, fell victim to the problem of selling a stock due to the Gain/Stock/Day Sell Rule during the last market correction, and turning right around and buying a new stock in the same industries that were correcting down.

The Balanced4 Ranking System has only a small part of the weightings that take into effect recent gain or loss. Under its Tech Rank Composite node it has the 3MoPctRet weighted at 32.5% with the Composite node weighted 20%. This gives a total weighting for that function of only about 6% in the total rank value. If a stock had a good gain in the first 2 months of the last 3 before a correction, then this Function will not reduce the total rank value of the stock. With many stocks that had been previously increasing over the last year prior to the correction, the other Functions in that Composite node, 3MoRet3MoAgo, 3MoRet6MoAgo, and 3MoRet9MoAgo, will still dominate the total weighting of that composite node.

This is why, with this Ranking System, the Port will continue to buy stocks that are turning down. Because of this effect I have added the Buy Rule; Pr4W%ChgInd > 5 to my version of this Sim. This requires the industry that a stock is in to be increasing over the last 4 weeks by 5% before the Sim will buy it. This is a very restrictive rule and will cause the Sim to not be fully invested frequently. With this type of Sim you need to do the Gain/Stock/Day calculation to see if this rule improves the return.

With respect to your second question, remember that I said that I use Buy and Sell Rules in my Sims that are tied to the Ranking System’s approach. The IReturn Ranking System is dominated by fundamental factors with the most recent momentum factor; Pr13W%Chg, at only 8% weighting. This system’s approach (which is a good one) tends to buy high value stocks that have not necessarily had a recent momentum move. Therefore, the Gain/Stock/Day sell rule is not tied to the Ranking System’s approach, and will frequently sell a stock before it is “discovered”.

The sequence at the end of my Sims (such as; a2b9s13) are my way of keeping up with what rules the Sim uses. The “a” is for the first page of the Sim, the “b” is for the Buy Rules, and the “s” is for the Sell Rules. I keep a record of the various sets or combinations of rules that I use, and after running many Sims I can glance at a list of Sim titles and know which set of rules each Sim uses without having to open the Sim and look at the Trading System page.

Denny :sunglasses:


Your input is valuable, because we, P123 members, have a tendency to adopt community sims and community ports; and sometimes, unknown to us, those sims and ports are less than perfect. For example they’ve got no laggard rules. And then when we use a port with no laggard rule, we can get frustrated and become less than happy because - at the time we started the port - we didn’t have a master list of buy and sell rules we could check it against. I know what I’m talking about because that’s exactly what I happened to me at least once. But now, thanks to you, we’ve got a master list, I’ve got a master list, and I thank you for that!


Attached is my own version of Dan’s spreadsheet. I’ve been using it as a start for sims & ports. Like Dan, I have not tested all these rules. When I find one that’s interesting in a community sim, I add it to the list. So don’t give me credit for them; they come from folks like Denny, Brian, Paul, Dan, Stenci, Rick, Glen and others.

I also keep Template sims with 24 (12 Buy, 12 Sell) of the frequently used rules, each preceded by a Boolean string:
Buy Rules: 1 &
Sell Rules: 0 or
To deactivate rules I just flip ones & zeroes. I’ve found this to be an easy way to experiment.

P123 Buy-Sell Rule Examples.xls (23 KB)

Very interesting post, thank you!

I often think that we should rely more on the ranking and less on the buy rules.
Buy rules like these:

MaxCorrel(40,1) < 0.3 SecWeight < 25 makes sense to me, but buy rules like these:

MktCap > 50 & MktCap < 1000 PctDev(60,5) < 0.2 & PctAvg(20,5) > 2 sound like… laziness!

I will try to be more clear: parameters like SecWeight or MaxCorrel make sense only in a portfolio, they are not stock factors, and cannot be used in a ranking.
But parameters like MktCap and PctDev could be used in a ranking system. And I think they should, because it doesn’t make any sense to buy XXX because MktCap=51 instead of YYY that has a higher ranking just because MktCap=50.

I think that all the stock factors should be in the ranking, not in the buy rules.
For example instead of this buy rule:

MktCap > 50 & MktCap < 1000 we should use this formula in the ranking:

eval(MktCap<30,0,eval(MktCap<100,(MktCap-70)/70,eval(MktCap<800,1,eval(MktCap<1400,(1400-MktCap)/600,0)))) I once tried to move these parameters from the buy/sell rules into the ranking, I failed at the first attempt, and the laziness toke over.
Has anybody ever tried?
Do you think is worth trying?



Yes, all the stock factors could be added to the Ranking Systems, IF, you want to develop a private one or one that works for only a small part of the community.

The Ranking Systems rank all the stocks, and each individual can or will only buy a select range of stocks that meet his/her investing style. Many factors like MktCap, Price, AvgVol, AvgDailyTot, etc, need to be selected with respect to what each member is comfortable with and can or should buy.

It is VERY time consuming to develop a new Ranking System that meets personal goals and have that system even come close to the performance of many of the public systems. I think that the time is better spent testing new factors added to existing systems that might improve a system’s performance, and time spent optimizing the weightings of a system’s factors.

It takes enough time for me to develop good, well thought out Buy and Sell Rules that meet my needs.
I am using 8 different Ranking Systems. I can’t imagine the time it would take to add those factors to 8 ranking Systems and get them to perform nearly as well as my Sims do now. It is just far easier and faster (lazy? OK, I’ll go with lazy) to develop personal Sims than personal Ranking Systems.

Denny :sunglasses:

I found that some of Denny’s sell rules in a port which I run using the TF-12 excellent ranking system could be replaced with some much simpler rules that yield >10% better annual return. There’s a 100% increase in turnover as well, but the port only holds 7 stocks.

Old Sell Rules:

Rank < 99 & nodays>20
GainPct< -20
PctFromHi < -15 & Rank < 99.

New Sell Rules

Rank < 99
GainPct< -15

With the new rules:

Annualized Return [color=royalblue]155.06%[/color]
Annual Turnover 688.96%
Max Drawdown -20.21%

The Old Rules:

Annualized Return [color=royalblue]143.56%[/color]
Annual Turnover 585.12%
Max Drawdown -20.09%

(Sim Date: 10/13/01 - 10/14/06)

Jerrod -
Could you explain how you toggle on and off your common buy rules. I have been trying to do this with the Excel Add-in, but have not quite figured it out. It would make my life a little easier. I do alot of cutting and pasting. Thanks

Jerrod -
Could you explain how you toggle on and off your common buy rules. I have been trying to do this with the Excel Add-in, but have not quite figured it out. It would make my life a little easier. I do alot of cutting and pasting. Thanks
[/quote]Glad to, William.
Each Buy rule is a compound statement that is true if either part is true. So instead of a simple filter like (Rank>99), I would write
0 or (Rank>99), which is logically equivalent.

To disable the rule, change the 0 to 1. Now that compound rule is always true, thereby disabling the filter portion (Rank>99).

Sell rules work similarly, except that the compound is true only if both parts are true. Thus a filter (Rank<99) becomes
1 AND (Rank<99). To disable the filter, change the 1 to 0.

There is a feature request here that would simplify this procedure by adding a checkbox or special “COMMENT” character, but it hasn’t generated much interest.

Looks like a lot of users are using this technique or turning buy/sell rules on/off. While it works, it makes sims run slower because the logic still gets executed. We’ll bump up the requested feature priority.

Jerrod & William,

Have you ever tried something simpler? For simplicity, you cannot beat the followings: “Rank > 99” (to enable the buy filter) and “Rank > -99” (to disable the buy filter).

Old buy rules:
0 or (Rank>99) … // Enable
1 or (Rank>99)… // Disable

New buy rules:
Rank>99…// Enable. Buy, if rank is higher than 99.
Rank>-99…// Disable. Rank > -99 is always true.

Old sell rules:
1 AND (Rank<99)…// Enable
0 AND (Rank<99)…// Disable

New sell rules:
Rank<99…// Enable. Sell, if rank is lower than 99.
Rank<-99…// Disable. Rank < -99 is always false.

Advantage #1: Your sim will be simpler and easier to write.
Advantage #2: Your sim will be easier to manage. There will be no more confusion about zeroes and ones.
Advantage #3: Your sim will be Fast.
Advantage #4: Save time and money. There will be no need for the feature request that Marco has just bumped up to higher priority.

All of the above should work in Excel.

I hope this helps.



Your recommendation will work fine for many of the simpler Buy and Sell Rules.
Buy is not workable for more complex Rules and even some simple ones. A few examples:

Buy Rules;
MktCap > 50 & MktCap < 500
SecWeight <15
MaxCorrel(60,1) < 0.5

Sell Rules;
NoDays > 20 and GainPct < BenchPct
PctFromHi < -20
Pr4W%Chg / 20 <.1 & NoDays > 30

You could reverse the > and < signs on some of them and make it work, but that is not simpler, and it is easy to over look when changing it back.

Denny :sunglasses:

Denny is right on both counts regarding the 0/1 switch.

First off, it’s easier to spot whether a rule is active or not just by looking at the first character.

Secondly, it’s easy to copy & paste the switch into all rules when developing a new sim.

Finally (with apologies for the cheap shot), without usiing the switch method, how would you deactivate these recently posted candidate rules?

(GainPct < -14 & Rank < 95) OR (GainPct < -20 & Rank < 98) OR Rank<90


Eval(HighestBar(#High,25,0)=1,1,0) OR Eval(HighestBar(#High,25,0)=2,1,0) OR Eval(HighestBar(#High,25,0)=3,1,0) OR Eval(HighestBar(#High,25,0)=4,1,0) OR Eval(HighestBar(#High,25,0)=5,1,0) OR Eval(HighestBar(#High,25,0)=6,1,0) OR Eval(HighestBar(#High,25,0)=7,1,0) OR Eval(HighestBar(#High,25,0)=8,1,0) OR Eval(HighestBar(#High,25,0)=9,1,0) OR Eval(HighestBar(#High,25,0)=10,1,0) OR Eval(HighestBar(#High,25,0)=11,1,0) OR Eval(HighestBar(#High,25,0)=12,1,0)

Denny & Jerrod,

I see the point you guys have made.

Naturally, the more complex buy and sell rules you guys create, the more likely that you guys will need additional features, like check boxes, just to be able to manage those highly complex rules.

Maybe I should use complex buy and sell rules, too. However, currently, I make serious attempts to keep them as simple as possible. I’m concerned about using too many rules, because too many (or too complex) rules mean data mining. And data mining usually leads to high sim returns, but low port returns. And if returns on my ports are low, then why did I go through this whole exercise (of creating complex buy and sell rules)? And, if I didn’t need the exercise, then why did I ask for the additional feature Marco has talked about?

I’m still undecided on this issue. As soon as I have some time, I will run a large number of sims, just to help me decide if I can keep all of my buy and sell rules simple. In my whole life, I’ve always tried to keep things simple.

But I see the point you guys have made.


Good morning Dan:

I’m rebalancing my portfolio and got a Sell on one of the stocks. The reason: Buy/Sell Difference. The rebalance didn’t replace thios sell order with a corresponding buy.

Any thoughts.

Judy G