Hi,
I am trading a future with 4 ocntracts trade size, with an entry strategy (A) with different entry signals; and exit strategy (B) with a mix exit signals: wtih trailing stop, time exit and target prive exit. I would like to add a "tight % trailing stop" to close half of the holding if triggered (i.e. 2 contracts), leaving the other half (2 contracts) to be exited by exit strategy (B). If a new entry signal is triggered afterwards, I would like to buy back 2 contracts (i.e. max holding still is 4).
How can I code it smartly?
Is there any sample that I can learn from?
What is the ReservedWord, inside of a Signal, to check the number of contracts at broker?
Thanks in advance!
Help: How to code multiple exits?
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Help: How to code multiple exits?
When you increase the complexity of your logic, even for merely one additional contract, the coding permutation goes up exponentially. You nolonger have the luxury of a "One-size-fits-all" coding you enjoyed while trading a "one-contract" scenario. (ie. other people's sample is not likely to help much). From your simple description above, you have multiple conditional scenarios, which requires multiple "cross-checks" before you can proceed to your order logics. Coding the BUY/SELL is not difficult, the devil is in coding the "cross-checks".Hi,
I am trading a future with 4 ocntracts trade size, with an entry strategy (A) with different entry signals; and exit strategy (B) with a mix exit signals: wtih trailing stop, time exit and target prive exit. I would like to add a "tight % trailing stop" to close half of the holding if triggered (i.e. 2 contracts), leaving the other half (2 contracts) to be exited by exit strategy (B). If a new entry signal is triggered afterwards, I would like to buy back 2 contracts (i.e. max holding still is 4).
How can I code it smartly?
Is there any sample that I can learn from?
What is the ReservedWord, inside of a Signal, to check the number of contracts at broker?
Thanks in advance!
The best suggestion I can give is...
1. draw a comprehensive flow chart before you start coding. (most people ignore this advice.)
2. read read read, and try try try... then test test test, and try again.
3. if time is not on your side, hire a professional programmer. If you have a profitable logic, there is no point in wasting time going around in circles just trying to save a few bucks.
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Help: How to code multiple exits?
Go to wiki,Hi,
::
What is the ReservedWord, inside of a Signal, to check the number of contracts at broker?
Thanks in advance!
look under 8 PowerLanguage Keyword Reference
look for the section Strategy Position