Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Translating DynaOrder to NT in EFS

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

    Translating DynaOrder to NT in EFS

    I am trying to convert an existing EFS script to use NT instead of DynaOrder, just to understand what I am doing is correct. Can someone from NT just verify if my logic below is accurate?

    In DO:
    orderid=dots5.call("BuyMarket","ER2","FUT",contrac t_exp,"",0,"GLOBEX","",contract_num);

    This function returns an orderid from DynaOrder, the "BuyMarket" function is declared as the following:

    function doInit() {

    dots5.addFunction ("BuyMarket", DLL.INT, DLL.STDCALL, "BUYMARKET", DLL.STRING, DLL.STRING, DLL.STRING, DLL.STRING, DLL.FLOAT, DLL.STRING, DLL.STRING, DLL.SHORT);

    }

    I omitted a bunch of other functions for ease of reading.

    Using NT, the orderid must be predeclared:

    myOrderId=1;

    At some point, the following function is defined:

    function NTBuyMarket(orderId, quantity) {
    return NTCommand("Place", "", "Buy", quantity, "Market", 0, 0, "", "", orderId, "", "");
    }

    I understand that you place the following in preMain:

    function preMain()
    {
    setPriceStudy(true);
    setStudyTitle("NT Sample");
    dll.addFunction("AvgEntryPrice", DLL.DOUBLE, DLL.STDCALL, "AvgEntryPrice", DLL.STRING, DLL.STRING);
    dll.addFunction("AvgFillPrice", DLL.DOUBLE, DLL.STDCALL, "AvgFillPrice", DLL.STRING, DLL.STRING);
    dll.addFunction("Command", DLL.INT, DLL.STDCALL, "Command", DLL.STRING, DLL.STRING, DLL.STRING, DLL.STRING, DLL.INT, DLL.STRING, DLL.DOUBLE,
    DLL.DOUBLE, DLL.STRING, DLL.STRING, DLL.STRING, DLL.STRING, DLL.STRING);
    dll.addFunction("Connected", DLL.INT, DLL.STDCALL, "Connected");
    dll.addFunction("Filled", DLL.INT, DLL.STDCALL, "Filled", DLL.STRING, DLL.STRING);
    dll.addFunction("GetDouble", DLL.DOUBLE, DLL.STDCALL, "GetDouble", DLL.STRING);
    dll.addFunction("GetInt", DLL.INT, DLL.STDCALL, "GetInt", DLL.STRING);
    dll.addFunction("GetString", DLL.STRING, DLL.STDCALL, "GetString", DLL.STRING);
    dll.addFunction("MarketPosition", DLL.INT, DLL.STDCALL, "MarketPosition", DLL.STRING, DLL.STRING);
    dll.addFunction("NewOrderId", DLL.STRING, DLL.STDCALL, "NewOrderId");
    dll.addFunction("Orders", DLL.STRING, DLL.STDCALL, "Orders", DLL.STRING);
    dll.addFunction("OrderStatus", DLL.STRING, DLL.STDCALL, "OrderStatus", DLL.STRING, DLL.STRING);
    dll.addFunction("SetUp", DLL.INT, DLL.STDCALL, "SetUp", DLL.STRING, DLL.INT);
    dll.addFunction("Strategies", DLL.STRING, DLL.STDCALL, "Strategies", DLL.STRING);
    dll.addFunction("StrategyPosition", DLL.INT, DLL.STDCALL, "StrategyPosition", DLL.STRING);
    dll.addFunction("TearDown", DLL.INT, DLL.STDCALL, "TearDown");
    }

    I could then place the order by the following command in my script:

    NTBuyMarket("MyOrderId", 1);

    What I am having a hard time understanding is what to expect back from the functions in terms of status codes. I control all of my order management through successive status code settings, so I just need to understand how these are mapped.

    Is there one example that can be posted to follow the lifeline of just placing a market order? The steps I am looking for is placing the order, getting the state of the order in terms of has it been executed, and then the fill price.

    Just as an example from your documentation:

    // Get the current status of an order.
    function NTOrderStatus(orderId) {
    return dll.call("OrderStatus", orderId, account);
    }

    I know if I place the following command:

    myOrderStatus=NTOrderStatus(myOrderId);

    I could get the status back, but without a mapping of the return codes, this proves difficult. Is there some documention I am missing?

    Regards,

    Thomas

    #3
    Return states are Strings?

    I take it that the return states are strings? So I would do something like the following:

    myOrderStatus=NTOrderStatus(myOrderId);

    if (myOrderStatus == "Filled") {

    . . . all commands once my order is filled

    }

    Does anyone from the NT team object if I post my send_order function once I translate all the calls? Not sure if that is acceptable or not?

    Regards,

    Thomas.

    Comment


      #4
      Certified NinjaTrader consultants are available for help here: http://www.ninjatrader.com/webnew/pa...injaScript.htm

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      26 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      192 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,234 views
      0 likes
      Last Post xiinteractive  
      Working...
      X