Posted 11/30/2010 16:02:12
|
|
|
|
Hi,
For some reason, the stop loss and take profit that I set doesn't show up on Interactive Broker for forex / future. The entry order executed successfully.
I found this warning though. Not sure what that means.
Position manager order updated: 60: Limit Sell EUR/USD @ 1.3 0/20000 - Submitted IB error/warning code 2109: Order Event Warning:Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed.
Position manager order updated: 61: Stop Sell EUR/USD @ 1.2 0/20000 - Submitted IB error/warning code 2109: Order Event Warning:Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed.
Live system window pending ticks: 1
The code is written as follow:
public class MySymbolScript : MySymbolScriptBase {
private bool isOpened = false;
public override void Startup() {
}
public override void NewTick(BarData partialBar, TickData tick) {
// Put your trading code here
if (!isOpened)
{
Position open_position = this.PositionManager.OpenPosition(this.Symbol, PositionType.Long, OrderType.Market, -1, 100, "TestBuy");
open_position.SetProfitTarget(1.3, TargetPriceType.AbsolutePrice);
open_position.SetStopLoss(1.2, TargetPriceType.AbsolutePrice);
isOpened = true;
}
}
public override void NewBar()
{
}
public override void OrderFilled(Position position, Trade trade)
{
// This method is called when an order is filled
}
public override void OrderCancelled(Position position, Order order, string information)
{
// This method is called when an order is cancelled or rejected
}
}
Can someone point me to the right direction?
|
|
Posted 12/2/2010 01:48:12
|
|
|
|
Do the PT/SL orders show up in the live pending orders window? Add the code I posted here to your OrderCancelled method, and see if they are being cancelled for some reason.
Thanks,
Daniel
|
|
Posted 12/7/2010 03:03:03
|
|
|
|
Sorry for late reply. I've been extremely busy recently.
I found the problem. I think we only place stop loss and take profit once the position has been opened. Just in case someone encounter the same problem as mine.
|
|
|
|