Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

eSignal DDL function format

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

    #31
    imported post

    The NTCommand with and without the strategy parameter has the same result in the NTSample.efs file in all me tests.

    What would I do to the NTCommand that currently doen't work correctly without the strategy parameter, to make it work correctly?

    Comment


      #32
      imported post

      Here is the code for the NTSample.efs file that has an NTCommand replacing NTBuyMarket("MyOrderId", 1).

      This will execute the order, but the other DLL calls return a value of 0 after the order is filled.

      /* Copyright (c) 2005, NinjaTrader LLC [email protected]. All rights reserved. */

      var dll = new DLL("NtDirect.dll");
      var orderPlaced = false;
      var printDone = false;

      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.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.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.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");
      }

      function main()
      {
      if (isLastBarOnChart() && NTConnected())
      {
      if (!orderPlaced)
      {
      // if (NTBuyMarket("MyOrderId", 1) == 0)// buy 1 unit at market, assign order id (optionally)
      if (NTCommand("Place","Sim101","Buy",1,"MARKET",0,0," DAY","","","","") == 0)
      orderPlaced = true;
      }
      else
      {
      // print some information on the current position and order
      debugPrint("Position size: " + NTMarketPosition("") + "\r\n");
      debugPrint("AvgEntryPrice: " + NTAvgEntryPrice("") + "\r\n");
      debugPrint("OrderStatus: " + NTOrderStatus("MyOrderId") + "\r\n");
      debugPrint("Filled #: " + NTFilled("MyOrderId")+ "\r\n");
      debugPrint("AvgFillPrice: " + NTAvgFillPrice("MyOrderId") + "\r\n");
      }
      }
      }

      // Get the average entry price of a position of an account. "account" is optional.
      function NTAvgEntryPrice(account) {
      return dll.call("AvgEntryPrice", getSymbol(), account);
      }

      // Get the average fill price of an order.
      function NTAvgFillPrice(orderId) {
      return dll.call("AvgFillPrice", orderId);
      }

      // Place a buy limit order. "orderId" is optional (set to "" it not applicable).
      function NTBuyLimit(orderId, quantity, limitPrice) {
      return NTCommand("Place", "", "Buy", quantity, "Limit", limitPrice, 0, "", "", orderId, "", "");
      }

      // Place a buy market order. "orderId" is optional (set to "" it not applicable).
      function NTBuyMarket(orderId, quantity) {
      return NTCommand("Place", "", "Buy", quantity, "Market", 0, 0, "", "", orderId, "", "");
      }

      // Place a buy stop order. "orderId" is optional (set to "" it not applicable).
      function NTBuyStop(orderId, quantity, stopPrice) {
      return NTCommand("Place", "", "Buy", quantity, "Stop", 0, stopPrice, "", "", orderId, "", "");
      }

      // Place a buy stop limit order. "orderId" is optional (set to "" it not applicable).
      function NTBuyStopLimit(orderId, quantity, limitPrice, stopPrice) {
      return NTCommand("Place", "", "Buy", quantity, "StopLimit", limitPrice, stopPrice, "", "", orderId, "", "");
      }

      // Cancel an order by its order id.
      function NTCancel(orderId) {
      return NTCommand("Cancel", "", "", 0, "", 0, 0, "", "", orderId, "", "");
      }

      // Cancel all orders at all accounts.
      function NTCancelAllOrders() {
      return NTCommand("CancelAllOrders", "", "", 0, "", 0, 0, "", "", "", "", "");
      }

      // Change an order by its order id.
      function NTChange(orderId, quantity, limitPrice, stopPrice) {
      return NTCommand("Change", "", "", quantity, "", limitPrice, stopPrice, "", "", orderId, "", "");
      }

      // Close any position of the current instrument at an account. "account" is optional (set to "" it not applicable).
      function NTClosePosition(account) {
      return NTCommand("ClosePosition", account, "", 0, "", 0, 0, "", "", "", "", "");
      }

      // Submits a NinjaTrader command.
      function NTCommand(command, account, action, quantity, orderType, limitPrice, stopPrice, timeInForce, oco, orderId, template, strategy) {
      return dll.call("Command", command, account, getSymbol(), action, quantity, orderType,
      limitPrice, stopPrice, timeInForce, oco, orderId, template, strategy);
      }

      // Indicates if the connection to NinjaTrader is established. 0 = connected, -1 not connected.
      function NTConnected() {
      return (dll.call("Connected") == 0)
      }

      // Get the filled of an order.
      function NTFilled(orderId) {
      return dll.call("Filled", orderId);
      }

      // Close all positions and cancels all order at all account.
      function NTFlattenEverything() {
      return NTCommand("FlattenEverything", "", "", 0, "", 0, 0, "", "", "", "", "");
      }

      // Get a double value by its name.
      function NTGetDouble(name) {
      return dll.call("GetDouble", name);
      }

      // Get an integer value by its name.
      function NTGetInt(name) {
      return dll.call("GetInt", name);
      }

      // Get a string value by its name.
      function NTGetString(name) {
      return dll.call("GetString", name);
      }

      // Get the market position of the current instrument at an account. "account" is optional (set to "" it not applicable).
      function NTMarketPosition(account) {
      return dll.call("MarketPosition", getSymbol(), account);
      }

      // Get a new unqiue order id.
      function NTNewOrderId() {
      return dll.call("NewOrderId");
      }

      // Get a string of order IDs of all orders initiated through the ATI of an account separated by '|'.
      function NTOrders(account) {
      return dll.call("Orders", account);
      }

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

      // Place a sell limit order. "orderId" is optional (set to "" it not applicable).
      function NTSellLimit(orderId, quantity, limitPrice) {
      return NTCommand("Place", "", "Sell", quantity, "Limit", limitPrice, 0, "", "", orderId, "", "");
      }

      // Place a sell market order. "orderId" is optional (set to "" it not applicable).
      function NTSellMarket(orderId, quantity) {
      return NTCommand("Place", "", "Sell", quantity, "Market", 0, 0, "", "", orderId, "", "");
      }

      // Place a sell stop order. "orderId" is optional (set to "" it not applicable).
      function NTSellStop(orderId, quantity, stopPrice) {
      return NTCommand("Place", "", "Sell", quantity, "Stop", 0, stopPrice, "", "", orderId, "", "");
      }

      // Place a sell stop limit order. "orderId" is optional (set to "" it not applicable).
      function NTSellStopLimit(orderId, quantity, limitPrice, stopPrice) {
      return NTCommand("Place", "", "Sell", quantity, "StopLimit", limitPrice, stopPrice, "", "", orderId, "", "");
      }

      // Gets a string of strategy IDs of all strategies of an account separated by '|'. Duplicate ID values can be returned if strategies were initiated outside of the ATI.
      function NTStrategies(account) {
      return dll.call("Strategies", account);
      }

      // Get the position of a strategy.
      function NTStrategyPosition(strategyId) {
      return dll.call("StrategyPosition", strategyId);
      }

      Comment


        #33
        imported post

        Then there is an error in your script
        a) original script works as expected
        b) you replaced NTBuyMarket and it's no longer working
        -> replacement has an error

        Again I want to advice you to do an exact (!) replacement first and next change parameter by parameter. Since you epxerience these issues, it does not make sense to change more than one thing at a time.

        Comment


          #34
          imported post

          Your documentation says that all the fields I am using are required. Are you suggesting that they are not required as stated in Commands and Vaild Parameters section?

          If so, which parameters can I eliminate?

          Comment


            #35
            imported post

            I suggest you go step by step:

            - NTBuyMarket: NTCommand("Place", "", "Buy", quantity, "Market", 0, 0, "", "", orderId, "", "");

            - your approach: NTCommand("Place","Sim101","Buy",1,"MARKET",0,0,"D AY","","","","")

            There is more than one parameter different, no?

            Comment


              #36
              imported post

              The Buy market command in the NTSample file is:

              NTBuyMarket("MyOrderId", 1)

              The stucture for the NTCommand that is shown as required in your Commands and Valid Parameters document is:

              NTCommand("Place","Sim101","Buy",1,"MARKET",0,0,"D AY","","","","")

              What parameters in the above NTCommand are not required, even though your documentation says they are required?

              Comment


                #37
                imported post

                Please do this:

                Your original function call is:

                NTCommand("Place","Sim101","Buy",1,"MARKET",0,0,"D AY","","","12TickBasic1","")

                change to this:

                NTCommand("Place","","Buy",1,"MARKET",0,0,"DAY","" ,"","","")

                Does this work? If yes, then add the next parameter until you reach what part of the function call does not work for you. Then we know where your problem is and can then advise.
                RayNinjaTrader Customer Service

                Comment


                  #38
                  imported post

                  The problem was inusing Sim101for the account parameter. By leaving it blank, everything works. When I put it back in, all the previous problems come back.

                  Furthermore, I have just now set up my live feed to my broker Alaron, and having done so, there are now 2 accounts available to choose from. Now that there are 2 accounts to choose from, when I use Sim101 as the account parameter, everything works properly, whereas passing the account parameter before caused malfunctions.

                  My conclusion is that when there is only one account in NT and you send an account parameter, then it causes problems. At least that was the case in all my testing. Hopefully it will be clear sailing from here.

                  Cheers

                  Comment


                    #39
                    imported post

                    Great.

                    For clarification, when you were having the problem, were you connected to eSignal or our Simulated Data Feed connection?

                    Ray
                    RayNinjaTrader Customer Service

                    Comment


                      #40
                      imported post

                      The Simulated Data Feed.

                      Comment


                        #41
                        imported post

                        Sorry Ray, I spoke too soon.

                        It is not working when I use Sim101 for the account parameter, it only works when I leave the account parameter empty.

                        What now?

                        Comment


                          #42
                          imported post

                          More Info:

                          If I fire a tradeWITHOUT the account parameter, and it is the first trade I fire after opening NT,the trade will fire. If I theninsert the account number and reload the efs file, the trade will not fire. If I then take the account parameter back out and reload the efs file, the trade will then fire.

                          If I fire a tradeWITH the account parameter, and it is the first trade I fire after opening NT,the trade will fire. If I thenremove the account number and reload the efs file, the trade will not fire. If I thenput the account parameter back in and reload the efs file, the trade will then fire.

                          In other words, whichever format I use on the first trade that is fired after opening NT (with or without the account parameter) dictates whether or not the account parameter can be used in subsequent trades, and that state will remain in force until NT is closed and reopened.

                          So far all this testing is being done using the Sim101 account on the Simulated Data Feed. I am running eSignal 7.91 & NT 5.0.1000.5. All theefs filesare being run in the eSignal Bar Replay Mode.

                          Comment


                            #43
                            imported post

                            That is correct. That is how it should work. Will update the Help-->Guide.
                            RayNinjaTrader Customer Service

                            Comment


                              #44
                              imported post

                              Good morning ninjatrader.

                              Thanks for the response, but which is correct? The functionality for my 1st question, or the way I set up the Account Connection for paper trading to Alaron, or both?

                              Warren

                              Comment


                                #45
                                imported post

                                Either is correct. Just stick to the same protocol. If you use empty string for account, then NT will use the Default account that is set under Tools-->Options. Anytime you make a function call, pass in empty string for account for the default account, pass in the account name for any other account.
                                RayNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by algospoke, Yesterday, 06:40 PM
                                2 responses
                                19 views
                                0 likes
                                Last Post algospoke  
                                Started by ghoul, Today, 06:02 PM
                                3 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                3 responses
                                45 views
                                0 likes
                                Last Post jeronymite  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                7 responses
                                21 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                10 responses
                                181 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X