Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Chris L.NinjaTrader Customer Service

    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.
        Chris L.NinjaTrader Customer Service

        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?
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,602 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X