I am struggling with a feature of managed approach where an "enter long" order not only gives you a +1 in long position, but also automatically cancels all other shorts. Having now investigating this for days I think the below would not be possible under managed approach.
Lets assume we have 10 possible signals:
1) price > MA (10) , then enter long (signal name Long1)
2) price > MA (20) , then enter long (Long2)
3) price > MA (30) , then enter long (Long3)
4) price > MA (40) , then enter long (Long4)
5) price > MA (50) , then enter long (Long5)
6) price < MA (10) , then enter short (Short1)
7) price < MA (20) , then enter short (Short2)
8) price < MA (30) , then enter short (Short3)
9) price < MA (40) , then enter short (Short4)
10) price < MA (50) , then enter short (Short5)
Obviously, lets assume we have a position of 5 Longs. Now Short 1 gets triggered and I want the strategy to short 2 contracts. S0 3 Longs then remain. Then Short 2 will be triggered and I will have only 1 long remaining. Then Long 1 can be triggered again and I am back with 3 Longs, etc...
I do not know how this can be coded using managed approach due to the fact that EnterShort order will immediately leave me with -1. Is there a way at all?
In case it is not possible, can please someone send me an example of codes for both managed and unmanaged so I can see the differences and learn myself on how to code unmanaged approach?
I really would very much appreciate your help as I believe position sizing is very important nowadays and I really do not have the feature that entry order closes all opposite positions.
Thanks for your help.
Comment