Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Flexible File Path

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

    Flexible File Path

    Hi Guys,

    im trying to read from a File that is called ZRTK.csv.
    If i acces it with path = NinjaTrader.Core.Globals.UserDataDir + "APData" + "TK" + "ZR"+ "TK"+".csv";
    it works properly.
    Now i want to automaticly switch to another file if i change the Master instrument.
    I tried it with
    path = NinjaTrader.Core.Globals.UserDataDir + "APData" + "TK" +(string)Instrument.MasterInstrument.Name + "TK.csv";
    or
    path = NinjaTrader.Core.Globals.UserDataDir + "APData" + "TK" +Instrument.MasterInstrument.Name + "TK.csv";

    but that crashes my indicator.
    Masterinstrument was ZR 01-20.

    Can you tell me what i did wrong? And how it is done wright?
    Thanks a lot
    Branpo
    Last edited by Branpo; 11-21-2019, 02:31 PM.

    #2
    Hi Branpo, thanks for your post.

    Look at your trace files under Documents\NinjaTrader 8\trace, are there any error prints coming from the indicator?

    Please note that file reading and manipulation is out of the scope of support I can provide, but I will try my best to assist.

    Comment


      #3
      Hi ChrisL,
      yes there are the following errors:
      2019-11-21 21:45:48:315 ERROR: Indicator 'Terminkurve': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
      2019-11-21 21:45:48:320 ERROR: Error on getting/setting property 'PaintPriceMarkers' for NinjaScript 'Terminkurve': Exception has been thrown by the target of an invocation.
      2019-11-21 21:45:48:320 ERROR: Unable to create instance of NinjaScript 'Terminkurve'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.InvalidOperationException: 'DrawHorizontalGridLines' cannot be set from this state. Please see the Help Guide article on 'DrawHorizontalGridLines' for more information. at NinjaTrader.NinjaScript.IndicatorBase.set_DrawHori zontalGridLines(Boolean value) at NinjaTrader.NinjaScript.IndicatorBase.CopyTo(Ninja Script ninjaScript) at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Co pyTo(NinjaScript ninjaScript) at NinjaTrader.NinjaScript.NinjaScript.Clone()
      2019-11-21 21:45:48:320 ERROR: Failed to restore Indicator 'NinjaTrader.NinjaScript.Indicators.Backtesting.Te rminkurve'. Most likely (a) the implementation changed or (b) one or more properties have been renamed or removed or (c) the custom assembly which implements this Indicator no longer is there.


      Comment


        #4
        Hi Branpo, thanks for your reply.

        If you're referencing Instrument.MasterInstrument.Name in State.SetDefaults, move the code to State.Configure.

        Comment


          #5
          Hi ChrisL,
          that helped that it doesnt crash anymore and doesnt produce any new trace errors.
          But it still doesnt work.

          I added the following lines to my code:
          if (!File.Exists(path))
          {
          // If file does not exist, let the user know
          Print("File does not exist.");
          Print(SymNewSchool);
          Print((string)NinjaTrader.Core.Globals.UserDataDir + "APData\" + "TK\" + SymNewSchool+ "TK"+".csv");
          return;
          }

          Ninjaoutput:
          File does not exist.
          ZR
          C:\Users\dboeh\OneDrive\Dokumente\NinjaTrader 8\APData\TK\ZRTK.csv

          The filepath there is correct. So i really dont know why it cant open the file.

          Comment


            #6
            Hi Branpo, thanks for your reply.

            It seems the path variable is wrong. Did you try printing this out to confirm it is correct?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            44 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            58 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            35 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            95 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            59 views
            0 likes
            Last Post PaulMohn  
            Working...
            X