Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto Trade with TradeStation

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

    Auto Trade with TradeStation

    Questions:

    To the traders using TradeStation, are you using the "Signal" file to code your buy and sell orders?

    I've just started this and the problem I'm having is that when I add the Strategy (which contains the Signal) to the chart, TS marks all the past buy/sell signals on the chart and of course each time issending a file with a OIF orderto Ninja.

    I'm I just missingsome code to stop it from looking atpast signals?

    Also on the Ninja website it states in "The Basics". "Once NinjaTrader has processed the Passthrough OIF, it will delete the file. You can use this event to determine when it is safe to send the next Passthrough OIF. Has anyone figured out how check for this event?


    Any ideas would be much appreciated.
    Any simple examples that someone might have wouldbe also good.

    Thanks, Happy Easter


    Zardoz

    #2
    imported post

    I do not use TS but your problems occur in all software.

    For your problem of sending orders on historical data, you will need to add some code that tells you if you are, now running in real-time. In other words, you are finished with the historical data.

    As to whether or not the OIF file has been deleted, hopefully there is FileExists() command in TS.

    You may want to look atthe TS example on the main web site. http://www.ninjatrader.com/doc_autom...adestation.htm

    Comment


      #3
      imported post

      Regarding whether a bar is an historical bar or a realtime bar, use the TS boolean condition "LastBarOnChart" as in:

      Code:
      IF LastBarOnChart
      
      THEN BEGIN
      
       // some code statement
      
       // OIF file output statement
      
      END;
      scjohn wrote:
      As to whether or not the OIF file has been deleted, hopefully there is FileExists() command in TS.
      The best statement to use for file manipulation procedures including FileExists() in TS can be found in the EL Collections DLL package provided by the user named "Bamboo". I would also look for Bamboo's code contribution in the thread called "FastFileAppend".

      Comment


        #4
        imported post

        Thanks a lot guys,

        aspTrader

        I had got a workaround but the "if lastBarOnChart" is better. My workaround was just to bring up NinjaTrader after I activated my Strategy and delete the file manually.

        As for the "FileExist", I'm not sure. Bamboo seems to have a different TradeStation then myself, probably the new edition. His EL Collections isan ELD file. TS 2000i supports ELA and ELS files.There is no FileExists command with TradeStation 2000i

        scjohn

        The example on the main website is more confusing than anything, but then I'm just a rookie at this. He uses a lot of fileappend commands when I thought one had to create a new file for each command to be sent to Ninja. I don't think there was one file create or PrintFile command in the whole thing.

        Anyway I got the basic Strategy working minus a few extras that I had to take out.

        Thanks again for you help!!!

        Zardoz







        Comment


          #5
          imported post

          Zardoz wrote:
          I had got a workaround but the "if lastBarOnChart" is better. My workaround was just to bring up NinjaTrader after I activated my Strategy and delete the file manually.

          As for the "FileExist", I'm not sure. Bamboo seems to have a different TradeStation then myself, probably the new edition. His EL Collections isan ELD file. TS 2000i supports ELA and ELS files.There is no FileExists command with TradeStation 2000i
          Hi,

          The LastBarOnChart is the standard way in TS to only activate an order in realtime. If your NT strategy related code is in a TS indicator AND you have "Update Every Tick" turned on then you'll need to do something in addition to that.

          Bamboo's code contributions run with the new Tradestation. I'm not sure of their status vis-a-vis TS 2000i.

          Comment


            #6
            imported post

            asp Trader, Hi

            I do use update-every-tick and I am using a signal off a 52 tick bar chart. As far as I can tell this has not been a problem so far. Maybe because I don't get multiple signals within one bar.

            The problem I'm having now it that every now and then I'm getting a "runtime Error" on my signal with the message "Error opening file". Iassume that is the order.txt filethat I'mcreating to send the command to Ninja. Was wondering if I'm getting this message because I'm trying to create the file the same time Ninja is polling for it?

            Has anyone else had this problem?

            This is frustrating.



            Zardoz







            Comment


              #7
              imported post

              Vincent help me please.

              This is crazy. I took out basically all my code and only left one file create statement and I'm still getting the error. Here is the code. Still getting "Error opening file"most of the time the singal is activated. Someone must have also had this problem?

              Thought that maybe Ninja was trying to create a file in the same directory at the same time like the updateor position.txt file that Ninja creates. Or maybe the polling is the problem.


              If KBLshortterm < OverSold
              then TabLong = 1
              else TabLong = 0;


              If TabLong = 1 Then Begin

              If Price > High of 1 bar ago and KBLMedterm > KBLMedterm of 1 bar ago
              Then Begin

              Print(File("c:\program files\ninjatrader 4\AT\order.txt"),"YM 06-05,,DAY,BUY,MKT,,,,,,,YM One,SIM-101,");

              End;


              End;


              Comment


                #8
                imported post

                Zardoz,

                You seem to be printing to a file that does not allow access. In TS8, the syntax for writing a file is the command FileAppend

                Here is a line in my TS strategy that writes my file to NT V3.027 to enter a strategy order on the ER.

                FileAppend("C:\Program Files\NinjaTrader\Ninja V3.027 Cash\AT\order.txt",
                "ER2,1,GTC,BUY,LMT,"+numtostr(Close,2)+",,,,,,FALS E,ER 2C 3.0T 4.0T,,");

                The numtostr command inserts the closing price of the bar into the file prior to it being written.

                Hope this helps.

                Merv



                Comment


                  #9
                  imported post

                  We do not have any TS Easy Language experience here and would not know what the issue is with your ability to write out files. Hopefully Merv's comments will be of value. Thanks for that Merv.

                  On another note, a tip for anyone accessing any NT AT update files. They should be copied to another folder then read. This can avoid any potential file locking issues.

                  Ray
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    imported post

                    Thanks Merv,

                    I'm using TS 2000i. It states the FileAppend command is not to create a file as one has to do for NinjaTrader but to add info into a file that already exists. As Ninja deletes the file after it reads it I need to create a new file. The Print command does work sometimes, just not consistently. I will however give it a go and see what happens. I have nothing to lose at this point.

                    Thanks Again

                    Zardoz

                    Comment


                      #11
                      imported post

                      Solved my problem. thx

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post Javierw.ok  
                      Started by timmbbo, Today, 08:59 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post bltdavid  
                      Started by alifarahani, Today, 09:40 AM
                      6 responses
                      40 views
                      0 likes
                      Last Post alifarahani  
                      Started by Waxavi, Today, 02:10 AM
                      1 response
                      18 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Started by Kaledus, Today, 01:29 PM
                      5 responses
                      15 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Working...
                      X