I have this strategy that looks for specific conditions around VWAP.
It is designed to always have a position during the session.
For example, if the price reaches a specific distance above VWAP, it will go long.
If, after a while, the price reaches a specific distance below VWAP, it will close the long position and go short.
if it does not reach the 'below VWAP' value, it will just exit the position at the end of the session.
The strategy also includes logic around a 'no trade period' during which no new trade can occur (only close of a existing position, if needed).
So because of this, it is important to sometime just close a position and not initiate the opposing trade (because it occurs in the -no trade period-)
The strategy is using EnterLong(), ExitLong(), EnterShort(), ExitShort, along with some tests on Position.MarketPosition.
For now, the quantity is always 1 and specific signal names are provided.
The problem is that once a position is initiated, if the conditions exists to create a reverse position, the resulting new position ends up with a quantity of 2.
Example:
1) Long initiated via a EnterLong(), with a quantity of 1 (the Control Center's Execution tab shows this as an 'Entry' and the position shows '1 L' ... all good)
2) At some point, a condition exists to reverse so :
2.1) an ExitLong() is done (Execution tab shows this as an 'Exit' and the position show '0 L' which is good)
2.2) if this does not occur in the -no trade period-, an EnterShort() is done
Looking in the Control Center's Execution tab, I can clearly see that an action with a signal name 'Close Position' is done, just after the ExitLong
This particular action appears 'system generated' as the strategy does not use a signal name labeled 'Close Position'.
The entry type on the execution tab for this line shows 'Entry' and the Position shows '1 S'
After that, the Execution tab shows a line for the EnterShort, with another 'Entry' and the Position is now at '2 S'
It should be noted that this only occurs when that strategy is running 'live' (on the SIM101 account)
When run under the strategy analyzer, there is no problem and the execution display in the Analyzer does not have any entry with the name 'Close position'
There is clearly something I am missing with the expected results using simple EnterLong(), ExitLong(), EnterShort(), ExitShort.
I would like to know :
a) where does the 'Close position' action comes from ?
b) why is there a different behaviour between 'live' and 'analyzer' for this ?
c) some proposed options to correct the issue (may use ExitLongStopMarket instead)
d) if an example of an 'always in' strategy exists, please share a link (I could not find one).
Thank you in advance for your help.
Cheers.

Comment