Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how about I/0 in ninja?

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

    #16
    The try/catch block in OnStartUp() is working as expected I think. If you are using your own filename it is string dest, and here is the OnStartUp() logic:

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] OnStartUp()[/COLOR][/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2] ....
     
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// If file at 'path' doesn't exist it will create the file. If it does exist, it will append the file.[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{[/SIZE][/FONT]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (useDefaultFilename == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]sw = File.AppendText(dest);[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]Print(DateTime.Now + [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" Running Export Data"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Writing to file: "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + dest);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Disable to close the file and allow access by other programs."[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]} [/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]sw = File.AppendText(defnamePath);[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]Print(DateTime.Now + [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" Running Export Data"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Writing to file: "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + defnamePath);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Disable to close the file and allow access by other programs."[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (Exception e)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]Print(DateTime.Now + [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" Exception caught in path and file variables"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Please check your path and file name and try again"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print ([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Exception Details: "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + e.ToString()); [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]MessageBox.Show([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Invalid Path. Please check your Path and Filename variables."[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Warning"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], MessageBoxButtons.OK, MessageBoxIcon.Stop);[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]sw.Close();[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]pathException = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]; [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Disable(); [/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
     
    [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    So the line in the Output Window after "Please check your path and file name and try again" should tell you what's up.

    A common one is the DirectoryNotFound exception. I've not seen the one you are getting. Perhaps try to create a txt file in Notepad and Save As using the same file/path and see if your system allows it?

    Comment


      #17
      FYI I found an error in the raw cs file posted earlier where I had and unused variable declared that messed with the Open[0] output.

      This is unrelated to the Permissions issue but here is the updated code if anyone stumbles on the this thread later.
      Attached Files

      Comment


        #18
        djkiwi I've added another Print() statement in the exception handler that might help. It will now also print the full path+ file name as part of the exception report.

        Give this one a try and let me know how you go. NT7 compile.
        Attached Files

        Comment


          #19
          thanks a lot!

          I have read c# help guide and the reply for these helpful friend.
          thanks a lot and I have catch the point.
          best regards!

          Comment


            #20
            Export Data

            Hi MXAS, thanks for your post on this, still trying to fix this issue. For now am happy just renaming the default file using the great little utility. I do have another mystery I was hoping you or Josh could provide some pointers.

            Basically I am trying to export historical volume delta data from April to current and cannot seem to export the historical. I've attached two charts. The first is the current 01-11 CL contract showing volume delta data (at the bottom of the chart) derived from recorded Zen tick data using the gomi recorder. The second is the 05/10 CL contract and shows the volume delta based on historical tick data I loaded in myself.

            The difference is when I export the data from 05-10 chart 2 the volume delta data does not show in the text file, only zeros show. All of the other data appears ok in the file though just not the volume delta data. Even though I can see it on the chart I cannot seem to get the data out. The 01-11 CL contract delta data shows up no problem. I know the historical volume delta data is stored in the mdocuments folder, so maybe it has something to do where the data is stored.


            Any ideas on how to resolve this issue would be appreciated. Thanks. DJ
            Attached Files
            Last edited by djkiwi; 12-17-2010, 01:24 PM.

            Comment


              #21
              Can't help you with that one, mate. There are no error checks in the code for database querries so you will need to use Print() statements to find out what syntax you need for that indicator to return what you want it to return.

              My guess is something is wrong in this: GomDeltaMomentum().DeltaMomo[0]);

              Comment


                #22
                another question

                anyone pls telll me.when I use the command Console.Writeline,where do the ninja print the result?thanks a lot.

                Comment


                  #23
                  Silverness, Console.WriteLine is only applicable if you are using/developing a console application and/or debugging from Visual Studio. If you'd like to display something in NinjaTrader, please use the Print() function, which will send output to the output window (Tools -> Output Window).
                  AustinNinjaTrader Customer Service

                  Comment


                    #24
                    problem

                    Hi MXASJ

                    Thank you for this indicator as it would solve a lot of my problems

                    But i have and issue i changed my computer clock to read what i think you wanted 19:01 01/03/2011

                    i put the indi on the chart and left the default settings as the were and created a D:/DATA folder

                    why is not been written or did i miss an instruction

                    thank you in advance

                    Comment


                      #25
                      Version 3.32 of the ExportData Strategy is the latest and is attached. You should not have to change your system clock as the Output DateTime format can now be selected in a drop-down list. It includes common formats and customizable one for your your Matlab or R preferences.

                      You should open the Output window when you enable the Strategy as most if not all error information can be found there.
                      Attached Files

                      Comment


                        #26
                        I did reset my clock to Windows default

                        tried strategy and got this error

                        Failed to call method 'Initialize' for indicator 'Atlasline_indicator': 'BarsInProgress' property can't be accessed from within 'Initialize' method

                        any clue????

                        Comment


                          #27
                          Can't help as that appears to be a problem with your code or your usage of the Atlas Line Indicator.

                          Comment


                            #28
                            now i removed the Atlas_line indicator i dont get any errors in the output window but i still dont get any file created

                            Comment


                              #29
                              On this Strategy statements will be sent to the output window if it is working, and if it is not. If no statements are printed to the output window, it means the stratgey has not been enabled.

                              Here is one that starts up OK:

                              Code:
                              **NT** Enabling NinjaScript strategy 'ExportData/87ab77398f0a4e4eab3ddb5355cf1e9f' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=True CancelExitOrdersOnDisable=False MaxRestarts=4 in 5 minutes
                              2011-01-05 21:12:29 Running Export Data
                              Writing to file: D:\Data\FGBL_03_11_1_Minute.txt
                              Disable to close the file and allow access by other programs.
                              Here is what happens when I Disable the Strat:

                              Code:
                              **NT** Enabling NinjaScript strategy 'ExportData/87ab77398f0a4e4eab3ddb5355cf1e9f' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=True CancelExitOrdersOnDisable=False MaxRestarts=4 in 5 minutes
                              2011-01-05 21:12:29 Running Export Data
                              Writing to file: D:\Data\FGBL_03_11_1_Minute.txt
                              Disable to close the file and allow access by other programs.
                              **NT** Disabling NinjaScript strategy 'ExportData/87ab77398f0a4e4eab3ddb5355cf1e9f'
                              2011-01-05 21:12:55 Terminating ExportData on FGBL 03-11 1 Minute Data
                              File written to: D:\Data\FGBL_03_11_1_Minute.txt
                              And if I try to write to Drive Z: I get a pop up window and this in the Output:

                              Code:
                              **NT** Enabling NinjaScript strategy 'ExportData/87ab77398f0a4e4eab3ddb5355cf1e9f' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=True CancelExitOrdersOnDisable=False MaxRestarts=4 in 5 minutes
                              2011-01-05 21:13:23 Exception caught in path and file variables
                              Path Z:\Data\FGBL_03_11_1_Minute.txt is invalid.
                              Please check your path and file name and try again
                              Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:\Data\FGBL_03_11_1_Minute.txt'.
                                 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
                                 at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
                                 at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
                                 at System.IO.StreamWriter.CreateFile(String path, Boolean append)
                                 at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
                                 at System.IO.StreamWriter..ctor(String path, Boolean append)
                                 at System.IO.File.AppendText(String path)
                                 at NinjaTrader.Strategy.ExportData.OnStartUp()
                              **NT** Error on calling 'OnStartUp' method for strategy 'ExportData/87ab77398f0a4e4eab3ddb5355cf1e9f': Object reference not set to an instance of an object.
                              Which tells me the path is no good.

                              What did you get in the Output window?

                              Comment


                                #30
                                i get nothing in the output window

                                i must admit ii never used a strategy before so maybe I am doing something wrong there

                                all i do is open the strategy the same way i would an indicator

                                I hope that is correct

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Today, 05:17 AM
                                0 responses
                                41 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                124 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                64 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                41 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                46 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X