IB TWS order management question.

Hi,

I'm trying to realize this setup for some time already, but didnt find any solution yet. It would be great if someone could help.

- I want to sell a particular stock to go short at the open by using an OPG market order.

- Calculated from the actual entry price I want to send a LMT order with a 2% profit target.

- If that profit target isnt reached, the position should get closed at the end of the day with a MOC order.

Much thanks in advance!
Saico
 
here is how this would be accomplished in tradelink (free and open source, works with IB and 16+ other brokers and feeds) :

Code:
public class MyStrategy : ResponseTemplate
{
   // enable profit and stop management
   OffsetTracker ot = new OffsetTracker();
   PositionTracker pt = new PositionTracker();
   void GotOrderCancel(long id) { ot.GotCancel(id); }
   void GotFill(Trade t) { ot.Adjust(t);  pt.Adjust(t); }

   // do strategy init
   void Reset()
   {
        // set up your targets
        ot.SendOrderEvent+=new OrderDelegate(sendorder);
        ot.SendCancelEvent += new LongDelegate(sendcancel);
        ot["IBM"] = new OffsetInfo(BarListImpl.DayFromAny("IBM").RecentBar.Close*.02m,0,1,0);

        // send entry order
        Order o = new BuyLimit("IBM",100,150); 
        o.TIF = "OPG";  // you may need to enable OPG support in IB connector in tradelink
        sendorder(o);
   }

   void GotTick(Tick k)
   {
         ot.newTick(k);

         // enforce end-of-day order
         if (k.time>155900)  
         {
             sendorder(new MarketOrderFlat(pt[k.symbol]));
             isValid = false;
          }
   }
}

google tradelink project or tradelink.org for more info
 
Back
Top