Using ExitLong() as second stop loss, but trailing stop also executes, turning what should be a long exit into a net short position.
Here is what I'm doing:
Strategy is calculated on bar close not each tick.
I'm using 2 data series.
[0] the primary chart series is my signal series
[1] the secondary series is the one I'm placing trades on
Thus: in the State>Configure section I am adding only 1 data series.
Note: the primary chart data series is not the same instrument as the data series I add and place trades on.
The issue occurs in market replay (have not tested to see if this occurs in live market)
1. I enter the position (inside of OnBarUpdate) by doing the following:
a. set trailstop
SetTrailStop(TradeType, CalculationMode.Ticks, TrailerSize, true);
where TradeType is a striing I set and TrailerSize is a user entered integer
b. establish a long position using a market order
EnterLong(1,Convert.ToInt32(DefaultOrderQuantity), TradeType);
2. On the primary data series (the chart)
I test to see if price as exceeded a threshhold.
If so, I submit an exitlong order on the secondary data series like this
ExitLong(1,0, "","");
The order and trailstop are established correctly, but the trailstop does not cancel after the position is exited.
Is there something else I need to do to make sure the trailstop is removed?
Thanks.
Comment