Announcement

Collapse
No announcement yet.

EFS Runtime priority

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

  • EFS Runtime priority

    I am developing an automated trading EFS that communicates with the order handling program through files . In order to send an order , cancel etc. it is required to write single line files to a directory that the other program can read them from . Periodically I get errors from the other program saying the the access the file I write because another process has the file . In my EFS I only have 3 lines of code where I open the file , write to the file and then close the file .

    Is it possible my EFS is not running to completion at that point and if so it is possible to ensure the EFS completes with some kind of process interrupt prevention code ???

    Thanks Bill

  • #2
    If you are doing this in real time (as I assume) and your code that writes to a file isn't protected by some code (or the global flag) to make sure it isn't run on every tick, or other code to prevent it from happening, then for any one bar you could be opening and closing that file many many times for any one bar.

    Could this be the issue?

    Garth
    Garth

    Comment


    • #3
      Bill,

      You may consider posting the code, I think you will get some better help that way. I suspect that Garth may be right, but without seeing, it makes it kind of tough. If you post, please post code that can be run, even though it may only be a snippet of your entire code.

      There are a number of board members that jump at trying to solve problems such as what you are experiencing when it is presented in this manner.

      Regards,

      Comment


      • #4
        Steve , I will see what I can do in that regard . It is a little tricky as I have globals operating between 2 timeframe charts and the program involved in reading the file from me is a 3rd party program from www.ninjatrader.com . His program reads single line files that I write from EFS to affect his order managment software . The single function that I use to cancel an order is :

        function ClosePosition()
        {var Close = new File("close.txt");
        Close.open("wt");
        Close.write("ES");
        Close.close();
        }

        This function is called in my program when I get a reversal signal while in a trade . NinjaTrader looks for these instruction files every 200 mSec. and then reads them to see what to do and once the instruction is executed it deletes the file and waites for the next instruction .

        Today in 1 hour I had 6 of these get read OK and 1 that failed because NinjaTrader complained the file was still open . I of course can't change Ninjatrader but I was wondering if I can put a lock on this code so it run's till completion as I know you can do in some real time environments . If you need a more complete example let me know .

        I asked the developer of NijaTrader if he had seen this before and he said nobody has gotten eSignal EFS to work with his program . He reported one other gentlemen had a similar problem and they gave up trying to solve it ....

        Thanks Bill

        Comment


        • #5
          Bill,

          I see your quandry... I am surprised you were able to experience one today, given that the file is open a small fraction of a milisecond.

          I attached a file I use to append lines to a file, for your review. I attached it only because I do this a little different and thought it may help. IMHO it is 6 of one, half dozen of the other either way you go.

          I would urge you to time how long it takes to open and close the file. I bet you it is not long at all (0).

          Congrats on getting it to work at all seems like you are ahead of the curve.
          Attached Files

          Comment


          • #6
            Thanks Steve , timing shows it takes 0.638 millseconds from the performance Monitoring tool to execute a small piece of code that does what my previous post shows .

            If I move my file variable to global it comes down to .535 millseconds BUT that does not change that I have the 3 statements in a row to open , write 2 characters and close the file so it would not affect the amount of time the file is open .

            I think there are only 2 options - get the 3rd party application to retry so that he can no longer claim nobody has gotten eSignal code to work with his system or have a new primitive in EFS that does all 3 steps in 1 go but even then I doubt they could squeeze much out of the time . This still is not a safe way to program - hoping you can get something done before your other program runs !

            I had been shying away form DynaOrder because of it's extra complexity but I think I understand why it may be required . I may have to bite the bullet an dive back into that program .

            Will see what Garth and NinjaTrader say tomorrow .

            Thanks again . Bill

            Comment


            • #7
              Should you only get one signal (of a specific type) per bar?
              Also what interval are you using?

              Garth
              Garth

              Comment


              • #8
                Yes I only get 1 signal per bar . The case that showed up the problem had me long on 1 bar and an exit signal on the next bar . There was 1 minute and 17 seconds between these signals . I am using a 125T ES chart to generate both signals . I frankly don't understand why there is a timeing conflict of this type and have just requested the NinjaTrader developer to put in a retry to see if it highlights another problem .

                I had other cases this close together today that worked fine .

                Bill

                Comment


                • #9
                  So, from the sounds of it, you already have some protection around the file code to make sure that it will only enter a specific signals file access code once per bar?

                  Garth
                  Garth

                  Comment


                  • #10
                    Garth , it is only possible to execute 2 file command's per bar . Once each bar I check a file that is used by NinjaTrader to return position status info and each bar I check for new signals . Both operate on different files though as that is the way the interface is designed . 1 set of files to give order instructions and 1 is used to report back what the current state of play is on the broker side of the equation .

                    Comment


                    • #11
                      Bill,

                      I measured the time to perform 100 file writes and closes at 234 milliseconds, which is about half of what u did, I am surprised it took that long.

                      Regardless, I use dynaorder edit - dynaOrder is no longer maintaining this software as of 9/2/2006 and IMHO what you sacrifice in complexity, you are provided additional flexibility. I use it through IB TWS. It is a nice package.

                      Regards,
                      Last edited by Guest; 09-02-2006, 06:08 PM.

                      Comment


                      • #12
                        Yep Steve , I agree now that I have tried NinjaTrader . I don't want to waste anymore time trying to trouble shoot the interactions . I got a note from him today saying he retries 3 times/second to read files so there is something fishy that I will leave alone and use DynaOrder . I almost got a version of my strategy working in it that I need to finish . In any event my debugging skills have progressed on this one anyway .

                        Thanks to you and Garth for helping out . Bill

                        Comment


                        • #13
                          NinjaTrader or DynaOrder??

                          Hi guys

                          I just got NinjaTrader for the purpose of doing some Automated trading. But after reading this thread I am not sure if I should not switch to DynaOrder before wasting too much time. I am not a programmer though, but do manage to get some EFS code out to generate signals and to some backtesting. Should that level of experience/ knowledge be enough to get started on DynaOrder or is it much more complicated?

                          TIA
                          Oz

                          Comment


                          • #14
                            DynaOrder is no more difficult than NinjaTrader. DynaOrder is based on a stronger foundation. I looked at several different packages and asked a lot of questons. DynaOrder is the best option currently available. Go to the web site and you can see all of the code that you will need to incorporate. The examples are excellent. You will be able to incorporate them into your own code with little change.

                            Comment


                            • #15
                              DO vs NT

                              Gavishti, thank you for your reply. I had a look at the DO site and it seems like incorporating the DO code is as easy as incorporating the NT code. What I was not able to get a feel for is the user interface of the DO software when just doing manual trades. Is that also as well presented visually and easy to manage as NT? If not, is it possible to run both DO and NT at the same time?

                              TIA

                              Comment

                              Working...
                              X