Submitting an order at a specific time

Discussion in 'Automated Trading' started by J.P., Mar 19, 2009.

  1. J.P.

    J.P.

    Using TWS DDE for Excel API, how can I automatically submit an order at a specific time?
     
  2. here's quick idea without using macros

    put the current time in a cell (eg c1)
    put desired send time in cell (eg c2)
    put the # of times to order has been sent in another cell (eg 0 in c3)
    put max number of times to send order in another cell (eg 1 in C4)

    insert an IF function into 4th cell (eg c4), that does something like:

    Code:
    
    if c2 >= c1
    and
    c3 < c4
    then
    DDE sendorder
    c3++
    
    
    
    using tradelink you could build a repsonse to do this like so:

    Code:
    public class timedorder : ResponseTemplate
    {
      // eg to send order at NYSE open
      int sendtime = 93000;
      int maxorder = 1;
     int orderssent = 0;
      public override GotTick(Tick tick)
      {
        if ((tick.time >= sendtime) && (ordersent < maxorder))
        {
           O(new BuyMarket("IBM",300));
           orderssent++;
         }
      }
    }
    
    
    above example would work with IB.
     
  3. J.P.

    J.P.

    Thanks tradelink! I'll try to use your top example (the one without using macros). To put the current time in cell C1, I only know to use the NOW() function. But it does not continuously update and I'm not sure how to get around that but I'll continue to work on it. But great idea; I think you've got me going in the right direction.
     
  4. J.P.

    J.P.

    I was hoping for a simple solution without using macros but there may not be one so I appreciate this link and I'll try to implement it.
    Best regards.