The “Eval” function allows partial sells, for instance:
Eval(close(0)<sma(50),0.5,0)
Will sell half if a position’s below the 50 bar sma. (See Help->Reference->Eval)
Is it possible to specify on which ticker the formula Eval(close(0)<sma(50),0.5,0) is applied?
I believe that if I enter Eval(close(0)<sma(50),0.5,0) in my portfolio sell rule, it will calculate the SMA on my combined holdings, but if I want the formula to be applied on the SPY (ETF) of the S&P500, how can I declare that in the formula?
The sell rule is applied to each holding individually, not the entire portfolio.
To limit to one holding, such as SPY, just logically and a ticker function in the sell rule:
Ticker(“SPY”) & Eval(close(0)<sma(50),0.5,0)
If you’re just starting out, it might be helpful to read the HELP->Tutorials or HELP->Reference sections of P123…
However, this will cause a 50% liquidation of every stock holding every rebalance period that the SPY is under its moving average. Is that what you are looking for?
Don’t be discouraged from asking questions. Yes it does help to read the documentation, but the platform can be overwhelming when you first start out and asking questions / getting answers can make the difference between staying or quitting.
Sister - buy rules don’t recognize “0.5”, only TRUE or FALSE. Steve R is also asking about use of a specific ETF for timing. Perhaps what he should be using is the Hedge/timing module.
my understanding is that it is not possible to use the hedging system in an ETF simulation or portfolio. It seems to work only for Stocks.
My objective is simple but even after reading the documentation and researching the forum (and even asking P123), I can’t do the following rules and it is really frustrating:
I have an ETF only list that is rebalanced every 2 weeks following my ranker
in the meantime, and on a daily basis, I want to check the overall trend in the market using a more wider ETF such as SPY (for the S&P500).
if the SPY or another ETF is crossing an indicator such as SMA, then I don’t want to wait for the next rebalance (which can happen to be in 14 days per example) to get out of the market. In fact, I want to sell my portfolio in 2 steps. The first step is to sell x% of the portfolio when the SPY crosses indicator #1 and then sell the remaining portfolio if SPY crosses the second indicator.
on the other hand, by checking daily the overall SPY trend, I want to be able to re-purchase my portfolio based on my ranker without having to wait for the next rebalance.
What I am not sure is if P123 can run 2 rebalance system concurrently to check different rules for different set of assets and then use one system to trigger the other system…
Without this kind of “cross-system”, I think there are a lot of limitations in the creativity you can apply.
BUT I am sure I don’t know enough of P123, so I must miss something here.
steverose - you should be able to do most of what you want to do. You have to “rebalance” daily. In the sim there is a setting. For ports, you have to rebalance manually every morning. Rebalancing every two weeks can be implemented with the sell rule Mod(NoDays,14)=0. However, you will have trouble setting the day of the week you want to rebalance on. You need to know the starting day of week for the sim and then it will maintain that day of week. This rule will skip weeks when holidays occur on the rebalance day so you need to have a way of accounting for this (if you care).
You will have to create your own version of CrossOver() and CrossUnder() as they do not support GetSeries(). You can create crossover as SMA(50,0,GetSeries(“SPY”))>SMA(200,0,GetSeries(“SPY”)) And SMA(50,1,GetSeries(“SPY”))<SMA(20,200,GetSeries(“SPY”)) .
To sell half you need to use the Eval statement as described earlier. Also you need to override your rebalancing rule as this would cause everything to be rebought.
You cannot buy half the quantity of each ETF. You can use the buy rule CashPct>50 which will keep 50% cash but it won’t scale back the qty of shares.
To re-buy all, you need to sell everything first i.e rebalance