Announcement

Collapse
No announcement yet.

Buy appearing on chart, but not getting variables back

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Buy appearing on chart, but not getting variables back

    Hi,

    my buy and sell orders are appearing on the chart, but I'm getting null values from my orders.

    PHP Code:
    nQty Math.round(50000/open(0));      
    orderID Trade.buyMarket({qtynQty}); 

    PHP Code:
    PrintOrder(orderID);
    Qty:          5784
    FillQty
    :      null
    FillPrice
    :    null
    Time
    :         null
    isStopLimit
    :  false
    isStop
    :       false
    isLimit
    :      false
    isSell
    :       true
    isSell
    :       false
    isBuy
    :        true
    Route
    :        null
    Limit
    :        null
    Stop
    :         null 
    What am I doing wrong?

    Thanks

  • #2
    Order Placement

    Without seeing content of your PrintOrder function it is difficult to see what the problem is...


    I think that the trading symbol is incorrectly mapped to your broker symbol.

    Please go to your Menu: Broker Management/Dictionary and Order Defaults and review the mappings.
    Please also check Order Defaults on the screen

    To see which order got executed, please check
    Menu: Trade/Account Management, go trough TABS: messages, trades
    and it should be quite clear, which order was received, to which account it was routed, and which symbol was traded



    I would also suggest to explicitly pass as many parameters as possible to buyMarket Order
    to ensure that the order is routed to right account, symbol and connection

    defaults do not always work...


    Sample code:

    if (Connection.isConnected())
    {

    OrderId = Trade.buyMarket(
    {
    "symbol": getSymbol(),
    "qty": nQty,
    "account": Trade.getCurrentAccount(),
    "connectionID": Trade.getCurrentConnectionID()
    }

    if (OrderId == null)
    {
    debugPrintln("**** ERROR **** OrderId is null on Long entry "
    + getSymbol(),
    " qty ", nQty,
    " account ", Trade.getCurrentAccount(),
    " connectionID ", Trade.getCurrentConnectionID()
    );
    }
    else // Successfully placed order
    {
    if (lDebug)
    debugPrintln("buyMarket OrderId:", OrderId, " ",
    + getSymbol(),
    " qty ", nQty,
    " account ", Trade.getCurrentAccount(),
    " connectionID ", Trade.getCurrentConnectionID(),
    " OrderId " , OrderId
    );
    }
    }
    }

    Comment


    • #3
      Superb! Will implement this Adam! Thanks for taking the time to help! Much appreciated!

      Comment

      Working...
      X