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
SetStopContract;
SetStopLoss(50 * 145);
setpercenttrailing( 50 * 195, 5);
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
SetStopContract;
SetStopLoss(50* LossTarget);
setpercenttrailing( 50 * PTarget, 5);
end
Else begin
SetStopContract;
SetStopLoss(50* 30000);
setpercenttrailing( 50 * 30000, 5);
end;