I think there is some bugs in the setstoploss and setpercenttrailing working with IB data. I am using TWS to trade HSIF. In my data source setting, I already set generate new tick if volume change. Also, in my chart, I am using the 1 minute trade price based on volume change. My chart showing data correctly and filter out all the zero price and zero volume correctly.
My stop loss and trailing strategy is very simple.
Code: Select all
SetStopLoss(50 * 145);
setpercenttrailing( 50 * 195, 5);
Basically my stop loss is 145 points and trailing at 5% start with 195 points profit. On 9/9/2011, my auto trade system generated a sells order at 19,991. The system immediately generate a stoploss buy order at 20135 which is correct because I set the trading cost for a round trip at $60 (around 1 point). I put my stop loss coding at the beginning of my signal. I guess that’s why each time the same stop loss order will regenerate which there is a new order placed (even that order is not executed).
The problem is immediately after the closing at noon, the system keep on generating buy order at 20135 and 999. The 999 trailing order is correct in calculation if the price is zero (Int(19991 *50 *0.5)/50) = 999. It should not be a problem since all orders are rejected by the system.
However, just at the opening in the afternoon, an order of 999 is generated and accepted by IB. This cause my strategy unexpected closed.
I believe that this is due to the data used by SetStopLoss and trailing is direct from IB without go through the custom setting such as filter zero price and based on trade volume. Will MC address this in the future?
Also, there is no way to turn off the setstoploss, I just amend my code to temporary increase the stop loss and trailing to a level that will not trigger during lunch time. I am not sure it can address the issue or not. I will test it tomorrow. Any better idea to fix the problem?
Code: Select all
Condition99 = Time of this bar < 1159 or time of this bar > 1331 ;
If Condition99 then begin
setpercenttrailing( 50 * PTarget, 5);
setpercenttrailing( 50 * 30000, 5);