Announcement

Collapse
No announcement yet.

Position.qty ( OrderID ), Order.fillQty ( OrderID ) return null

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

  • Position.qty ( OrderID ), Order.fillQty ( OrderID ) return null

    Trade.setLiveTrading(true);

    Efs is active. Both buttons are enabled.

    OrderID has a valid ID string.

    Order.state ( OrderID ) is always 32 which seems to be Order.STATE_PLACING.

    Why won't any order or position statuses give me a value?

  • #2
    I meant Position.qty ( PositionID )

    Comment


    • #3
      My trade was:

      var OrderID = Trade.buyMarket(sSymbol, zSharesFifth );

      Comment


      • #4
        I am using IB as broker

        Comment


        • #5

          Hello diesel, I have a feeling that if you pass Order.state(orderID) to the PrintState function below (PrintState(Order.state(orderID)), that you're going to get "Unknown ORDERSATE" which apparently equals 32. Is "zSharesFifth" the number of shares that you want to buy? It would need to be, you haven't offered enough information for me to understand your issue. I'm going to attach 2 files, one that you can adapt to either manually trade with the buttons, or you can comment out the drawMyButtons() function and call the functions with an auto-trading approach. The second file ("LibEFSAT") needs to be saved as a library file (".efsLib") in Interactive Data's "LibraryFunctions" folder by changing "Save as type" at the bottom of the "Save script as" window to ".efsLib". This will allow you to access all of the functions in the script by using dot notation and preceding the function calls with "LibEFSAT.". If you choose not to go the library route, then you would need to delete the LibEFSAT global variable from the first script and then going through the rest of the script with "Find and Replace" and have it replace "LibEFSAT" with ""...nothing, essentially just deleting it while noting what all of the functions are that follow "LibEFSAT." and then copying them from the second file and putting them into the first file because the first file will need them to compile and work. I created the "LibEFSAT" file by deleting preMain, main, and the global variables and other things that didn't belong in a library file from eSignals "EFSAT_EXAMPLE_2014_V2.02" file, that way I can access all of the functions from my programs without having to clutter them up with all of the EFSAT functions. In the first script, there are a bunch of function parameters that you can change with the "Edit Chart" dialog box, including nQty which I have set at 1. CAREFULLY look the first script over and add the needed info like your account numbers, I have included notes that you should be able to follow to where the code will work for you. I have been using it flawlessly for about a year now, so I know that it works, I'd like to suggest that you start out using it with the buttons so as to gain an understanding of it before you move on to using the functions for auto-trading. In case that you're unaware, let me mention that you need to hold the "Shift" key down before you click on a button in order for the button to work. I'll check back here in a while in case you have problems or questions, good luck with your trading and Merry Christmas!

          function PrintState(Orderstate)
          {
          switch(Orderstate)
          {
          case Order.STATE_PARTIALFILL :
          return "STATE_PARTIALFILL";

          case Order.STATE_PLACING :
          return "STATE_PLACING";

          case Order.STATE_CANCELING :
          return "STATE_CANCELING";

          case Order.STATE_UPDATING :
          return "STATE_UPDATING";

          case Order.STATE_FILLED :
          return "STATE_FILLED";

          case Order.STATE_CANCELED :
          return "STATE_CANCELED";

          case Order.STATE_REJECTED:
          return "STATE_REJECTED";

          case Order.STATE_WORKING :
          return "STATE_WORKING";

          default:
          return "Unknown ORDERSATE";
          }
          }
          Attached Files

          Comment


          • #6
            Thanks so much. I will check this out. I'm glad someone else is involved in the efs-at.

            Comment


            • #7
              Hello Diesel...you are welcome. I noticed today that when I first launch eSignal that the TradeButton script causes an error message that forces me to reload it to get the script to load properly. Previously I didn't have a default value for "gOnSymbolMap", so I decided to put one in as true, I think that this is causing the PrintSymbol(symbol, connection) function to be called and since I'm not connected to IB right now, it's causing the program to crash after which it needs to be reloaded. So where it says "
              setDefault(true);" below, change it from true to false and also toggle it to false in the edit chart dialog box, or remove the program from your chart and then add it back to your chart after you have made the change to the code below.

              fpArray[x] = new FunctionParameter("gOnSymbolMap", FunctionParameter.BOOLEAN);
              with(fpArray[x++]){
              setName("onSymbolMap");
              setDefault(true);
              }

              Comment


              • #8
                Thanks again, LetUsLearn. I will do that and see what new info it tells us. Thank you

                Comment


                • #9
                  Hi, Need help for auto trading with IB Broker. My email id is [email protected].

                  Comment

                  Working...
                  X