Folks,
I have a rotation strategy in Amibroker which is based on AAA. It was developed in collaboration with TrendXplorer,(
http://indexswingtrader.blogspot.com/) Would like to convert to a Wealth-Lab strategy
It is based on deriving a composite rank from Momentum, Correlation and Volatility Ranks. In the Fidelity Sector Fund Rotation strategy code, I see it ranks by Momentum. But I need a way to rank by Correlation and Volatility as well and be able to derive a composite rank for every symbol in the DataSet. Composite rank can then be used to pick the top 1,2, or 3 symbols from the DataSet.
Can this be done in Wealth-Lab? If so, can someone provide a sample code.
if you like, I can share the Amibroker code.I am new to Wealthlabs and still learning the ropes.
Many Thanks,
Size:
Color:
QUOTE:
But I need a way to rank by Correlation and Volatility as well and be able to derive a composite rank for every symbol in the DataSet. Composite rank can then be used to pick the top 1,2, or 3 symbols from the DataSet.
Please check out this
FAQ > Rotation strategies >
I need other rotation rule other than the built-in RSI.This downloadable strategy presents an example of combined ranking by averaging an indicator with 3 periods:
Efficient Rotation Strategy (Rev. C)Mixing two rankings to arrive at a new list (medium complexity):
Combined rotation/ranking question
Size:
Color:
Thanks Eugene.
Do you know how to code for triggering the rotation strategy to enter/exit positions before close on the last day of the month? Basically I would like to have the strategy evaluate only on the last day of the month.
Size:
Color:
Size:
Color:
Thanks, Eugene. Much appreciated. I think the coding approach may suit my needs.
Next question is about position sizing. Strategy that i am considering to build, will pick a maximum number of 3 symbols based on relative strength only if absolute momentum (i.e. 3 months ROC) > 0. So, the selection may return etiher 1 or 2 or 3 symbols. If selection returns 3 symbols, then i would like to invest 33% equity in in each of the symbol
But if it returns only 1 or 2 symbols, I would like to allocate remaining equity to one of the cash proxy ( IEF, SHY, BIL) based on their 3 month ROC > 0 as per the following pseudo-code:
CODE:
Please log in to see this code.
How can I achieve this in Wealthlab?
Thanks,
Size:
Color:
Size:
Color:
Thanks for pointing in the right direction, Eugene.
Using the Priority Pos Sizer, I was able to define 33% allocation for each of the 1, or 2 or 3 symbols selected. But on running the strategy, I see a popup saying "some of the trades were not included". Need your help !!!!
Please find the code below for your reference.
CODE:
Please log in to see this code.
Size:
Color:
Nice code. Unfortunately, there's not much I can suggest (and
this FAQ doesn't really apply):
1. Reduce the position size as much as possible (25%, 20% etc.)
2. Bump up Margin Factor slightly above 1 (or any even number for this matter) e.g. 1.05, 2.05 etc.
3. If you weren't using the Position Priority PosSizer, I'd recommend activating the following options in the Position Options PosSizer: "Skipped Trade Solution" (but here it's not applicable due to use of AtClose orders) and Max Open Positions > "For last position, use all what's left".
Size:
Color:
Both your suggestions 1. and 2. works - When I reduce the position size to 15%, OR increase margin factor to 2.01.
But, I am unsure if system performance is getting reduced by doing so. Do you know if this workaround is due to a Wealth lab issue OR should I consider developing a custom PosSizer?
Thanks,
Size:
Color:
The system performance is certainly affected by reducing the position size twice to 15% due to a lower exposure (this leaves a lot of cash uninvested). I'm fine if MF 1.01 (2.01 etc.) works for you.
Size:
Color:
In live trading, will MF set to 2.01 cause rmargin trades? Is there any other alternative to ensure cash trades only and optimal fully invested system? Do you think writing a custom PosSizer is a solution?
Also, noticed that on changing the number of positions to 2 in lieu of 3, increasing Margin Factor to 2 or even 10 doesn't work
Size:
Color:
QUOTE:
In live trading, will MF set to 2.01 cause rmargin trades?
In live trading, you'd rather use Raw Profit. Please find more insight in the User Guide: Reference > Data Panel > Position Size Control.
QUOTE:
Also, noticed that on changing the number of positions to 2 in lieu of 3, increasing Margin Factor to 2 or even 10 doesn't work
If that means there's no effect on the trades not taken after reducing the number of allowed open trades to 2
and leaving the 15-25% position size, then it's expected. Like I said, the effect of reduced exposure is taking place. Your system's exposure % can be seen on the Performance tab.
Re: vague "doesn't work" - recommended reading:
How to Report Bugs Effectively >
"It doesn't work". ;)
QUOTE:
Do you think writing a custom PosSizer is a solution?
Let's say that we've developed two workarounds for this peculiarity (in
Position Options, "skipped trade solution" and "use all what's left") and neither of them is the silver bullet.
Size:
Color:
Sorry, I should have been more explicit. By saying "doesn't work", I meant it resulted in the original problem of reduced exposure, as you alluded to.
Basically, I would like to invest the remaining cash after allocation into a cash proxy ETF.
For example:
if the number of positions parameter is set to 2 and if only 1 is selected, then 50% goes into the selected position and the other 50% goes into cash proxy ETF.
If the number of positions parameter is set to 3 and if 2 are selected, then 33% goes into each of the selected position(i.e total 66% for 2 positions) and remaining 33% goes into cash proxy ETF
Can Position Options, help me with this? Earlier, with Priority Position sizer, i was planning to simply set the priority for cash etf for system to allocate remaining funds.
Thanks,
Size:
Color:
Position Options supports an ability to set % equity for a Position programmatically:
QUOTE:
The "Use .Tag" button, when enabled, allows to define the Percent-Equity or Max % Risk input programmatically i.e. in your Strategy: for instance, according to some technical or fundamental event. The combo box switches the position sizing from percent equity to max % risk. You have two options for passing the percent as a double value to the PosSizer:
Either in the LastPosition.Tag property
Or, if your Strategy employs .Tag for its own purposes, as the parameter of the SetShareSize method. For this to work, together with Use .Tag you should click on the Use SetShareSize button on the left.
Size:
Color:
Thanks, my friend. Perhaps, Use.Tag is the solution. Will try it out and let you know.
Can I get around the limitation of "Skipped trade position", with use of "AtClose" orders if I try to allocating 100% of equity using the Use .Tag feature?
Size:
Color:
No.
Size:
Color:
If Raw Profit mode which is recommended for live trading is using Fixed Size, then I feel all efforts to achieve dynamic allocation is not quite useful, unless we develop a Custom PosSizer that can be used consistently in both backtesting and realtime environments.
Any thoughts?
Size:
Color:
I stumbled upon this Position Tracking code from Cone that appears to enable granular, dynamic allocation of funds. This maybe the solution to my problem. Will try and see how it goes.
Portfolio Equity TrackerThanks,
Size:
Color:
Thank you for sharing this AAA strategy code. I am trying to test the code on a set of ETFs using raw profit mode and got lots of identical buy orders on the same bar. I could not figure out why, please help me. Thank you in advance!
Size:
Color:
Size:
Color:
Yes it does, thank you Eugene!
Size:
Color:
Hi, crk31174 and cal777,
I have been observing the TrendX strategy live on their website for several months. TrendX does not publish any long term historical or simulated results for the strategy, and I have been wishing for said results in order to better evaluate the strategy.
Lo and behold, I stumbled upon this thread! If you have successfully backtested the TrendX strategy (or even a good approximation), what is your opinion? Does the strategy backtest well?
Size:
Color:
With a typical weekly basis rotation strategy, I would like to signal the closing price on Friday and execute at the opening price on Monday.
Also, I would like to have an alert, but what should I fix in this code?
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
With a typical weekly basis rotation strategy, I would like to signal the closing price on Friday and execute at the opening price on Monday.
Also, I would like to have an alert, but what should I fix in this code?
As suggests the Wiki FAQ (
Alerts are not triggered):
Are your strategy using AtClose orders? These are not going to produce an alert. Check out the WealthScript Programming Guide: Programming Trading Strategies > Alerts > How to: Alert for AtClose Signals.As a simple alternative, tweak the code to trigger at next open:
CODE:
Please log in to see this code.
Size:
Color:
Thank you. It worked well on a weekly basis,
>Are your strategy using AtClose orders?
No. I use AtMarket orders.
Size:
Color:
QUOTE:
>Are your strategy using AtClose orders?
No. I use AtMarket orders.
But your code in post #23 did use AtClose orders. Anyway I believe you've changed that now.
Size:
Color:
I tried a quarterly AAA using code in post #23 in the default index folder, is this a realistic trade?
In other words, is it possible to trade according to the backtest?
The strategy parameters are
CODE:
Please log in to see this code.
Size:
Color:
On the surface, I don't see any blunt peeking into the future here.
It would be off topic to discuss it in this thread but I'll mention that not all symbols in the Indexes DataSet are tradable e.g. ^VIX. Many indices not necessarily trade in Dollars e.g. ^GDAXI. So it may be a comparison of apples to oranges.
Size:
Color: