I'm trying to build a Long-Short system system where Open rules (based on a ranking system of fundamental and technical indicators) and different from Close rules (which has different technical rules) - so, i cannot use the same sort-ranked list to open and close positions.
The logic is something like -
// Long ..
If (OpenLongPositions.count), Close if Sell Rule <e.g. Uptrend> is complete>
If (OpenLongPositions.count < MaxLongPositions) Buy (based on Ranking)
// Short ..
If (OpenShortPositions.count), Cover if Cover Rule <e.g. Downtrend is complete>
If (OpenShortPositions.count < MaxShortPositions) Short (based on Ranking)
Could you point me to some sample code that achieves this?
I couldn't find any sample code in Rotational Startegies folder, as those strategies are simplistic - they're Long-only and buy and sell based on a single sorted ranking list.
thanks
Kiran
Size:
Color:
There are examples on the forum which use multiple lists for ranking (
like that) or based on conditions for exiting other than the ranking. But I don't think you need to focus on Rotation systems since your trading idea is somewhat different. Two ideas off the top of my head:
1. Why not simply code it as a multi-position system taking Long + Short positions?
2. Code two different systems, be they rotational or not, and combine into one using Combination Strategy feature.
Size:
Color: