How would I write an Eval rule (or equivalent) to set the maximum # of positions? In other words, if such and such a condition is met, limit the number of stocks to X positions.
Thanks,
Ed
How would I write an Eval rule (or equivalent) to set the maximum # of positions? In other words, if such and such a condition is met, limit the number of stocks to X positions.
Thanks,
Ed
You could try using “cashpct>100-X or Condition=False” as a buy rule, which will force the port to use X% of your total port value toward purchasing stocks if Condition is True. You’ll probably need to adjust the 100-X to 100-X-Y to account for growing position sizes.
Ok thanks. But I’m getting an error with “cashpct”, telling me it’s an invalid rule.
Assume you have a 10 stock portfolio setup and you want to limit the number of stocks to 5 when the Vix is above 30:
BUY RULE
Eval(close(0,$VIX)>30, RankPos<6,1)
SELL RULE
Eval(close(0,$VIX)>30, RankPos>5,0)
hth,
Florian
Thanks Florian, that works!
I’m having trouble getting that RankPos rule to work in a Screen. Does it only work in Portfolios or Simulations?
I used cashpct>20 , for example, in one of my sims, and it worked fine, but if you found something better, that’s good too.
Thanks guys but none of these rules appears to work in a Screen. Any other rules that might? Thanks.
Eval(close(0,$VIX)>30,FOrder(“Rank”)<6,Price>0) using Florian’s example above.
Consider using [font=courier new]#Previous[/font] to include preceding criteria in [font=courier new]FOrder[/font], otherwise you’ll simply be intersecting [font=courier new]RankPos < 6[/font] with the other criteria.
Thanks Aaron, that works! Appreciate it.
Revisiting this topic … I’m using a buy rule that is intended to reduce the # of positions under certain market conditions, e.g.,
Eval(sma(5,0,#SPEPSCY) < sma(18,0,#SPEPSCY) and Close(0,Getseries(“$SP500”)) < SMA(180,0,Getseries(“$SP500”)), FOrder(“Rank”)<=4, price > 1.75)
When I use this rule in a screener, it works as intended and reduces the positions to a maximum of 4. But when I run a simulation with this rule the model goes entirely to cash. Here’s a screenshot below. What’s the issue and what’s the fix?
Maybe the issue is forder? In a sim I’d just use rankpos <= 4.
I tried RankPos<=4, same results.
I tried the following and it worked for me:
BUY RULE
Eval(sma(5,0,#SPEPSCY) < sma(18,0,#SPEPSCY) and Close(0,Getseries("$SP500")) < SMA(180,0,Getseries("$SP500")), FOrder("Rank")<=4, 1)
SELL RULE
Eval(sma(5,0,#SPEPSCY) < sma(18,0,#SPEPSCY) and Close(0,Getseries("$SP500")) < SMA(180,0,Getseries("$SP500")), FOrder("Rank")>4, 0)
Perhaps the intersection of the given buy rule w/ any other buy rule(s) is causing no stocks to pass. If there are other buy rules, try disabling them one at a time.
Walter
Seven sister/ Walter,
I want to sim to sell 50% of all 10 position(stocks) and enter 50% Bond during my market time entry.
And Sell the bond portion and enter all 100% in stocks when market time exit.
Without using hedge and margin account.
Please, let me know how to use p123 for this requirement.
Thanks
Kumar
Kumar, you can’t have stocks and ETFs in the same simulation.
Thanks guys but I’m encountering the same issue, the simulation goes entirely to cash even with the FOrder rule. Any other suggestions?
Thx,
Ed
P.S. (Walter: I’m running this model is a screen, there are plenty of stocks that pass the existing buy rules).
Follow-up:
Here are some screen shots that illustrate the difference, the first is from the Screen, which uses this rule to limit the stocks:
Eval(sma(5,0,#SPEPSCY) < sma(18,0,#SPEPSCY) and Close(0,Getseries(“$SP500”)) < SMA(180,0,Getseries(“$SP500”)), FOrderOLD(“rank”,#All,#desc,#Previous)>=1 and FOrderOLD(“rank”,#All,#desc,#Previous)<=4, price > 1.75)
And then the second screen shot is from the simulation, which uses this rule,
Eval(sma(5,0,#SPEPSCY) < sma(18,0,#SPEPSCY) and Close(0,Getseries(“$SP500”)) < SMA(180,0,Getseries(“$SP500”)), FOrder(“Rank”)<=4, 1)
As you’ll see the Screener works beautifully, still allows up to 4 stocks, but for some reason the simulation goes entirely to cash. Suggestions for the Sim?