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

Read/Write to Google Sheets using Google.API

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

    Read/Write to Google Sheets using Google.API

    Hi, I've seen a few others have asked this in the past but I can't really see a perfect answer.

    I'm trying to read and write to a google sheet. I've got it all working on a custom project but obviously would prefer/need to use it in Ninjatrader.

    The problem is you can't install the packages needed to use Google.Apis.

    I did see someone suggest building the dll files in another project which I have done and then copying them into bin/custom but I can't seem to get that working.

    I am a developer (not an expert in c# though) so if anyone could help out that'd be great.

    Thanks,

    Tarik


    #2
    Oh and I'm using Microsoft Visual Code as my IDE

    Comment


      #3
      Originally posted by tarikmedjber View Post
      The problem is you can't install the packages needed to use Google.Apis.
      What can't you?
      What do you mean by 'install'?

      Please note:
      Packages installed via NuGet are not immediately usable by NinjaTrader,
      there are additional steps.

      Hmm ...
      Do you mean adding references for the Google API assemblies to NinjaTrader?

      Good reading here and here.

      Summary:
      Step 1: Copy the DLL files into your 'NinjaTrader 8/bin/Custom' folder.
      Step 2: Open the NinjaScript editor, edit any file.
      Step 3: Right click menu, select References to add the references.
      Last edited by bltdavid; 12-11-2022, 01:24 PM.

      Comment


        #4
        The summary steps have worked perfectly David. thank you very much for the help!!

        Comment


          #5
          David, do you have any idea why
          " (var stream = new FileStream("path to credentials json", FileMode.Open, FileAccess.Read))"
          is struggling to be deserialized ?
          Error deserializing JSON credential data.
          Seems like versions somewhere may be incorrect due to working on a old.net version.

          https://stackoverflow.com/questions/...gle-sheets-api

          Comment


            #6
            Seems like I have the latest version Newtonsoft.Json {13.0.2} installed. Maybe I need to decrease the version because we're running an old .net version?
            ​

            Comment


              #7
              Hello tarikmedjber,

              Thanks for your posts.

              If you are wanting to use the Json Dll's from NinjaTrader, you could add a reference for the .NET Framework 4.5 compatible Newtonsoft.Json.dll. This will work with .NET Framework 4.8 and NinjaTrader.

              This DLL can be fetched from Nuget and is then stored: C:\users\USERNAME\source\repos\YOURAPP\packages\Ne wtonsoft.Json.13.01\lib\net45\Newtonsoft.Json.dll

              This DLL can then be copied into bin/Custom for normal distribution.

              Please let me know if you have further questions.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Hey Brandon,

                So I have added a Newtonsoft.Json dll file into the bin/custom, and then referenced this in the NS Editor.

                But still no luck. I even used the dll file this user said works for him https://ninjatrader.com/support/foru...on#post1037478

                I've attached screenshots.


                Attached Files

                Comment


                  #9
                  Hello tarikmedjber,

                  Thanks for your note.

                  It could be that the version of Newtonsoft that the community member supplied is not the correct version. Note from post # 7 that you would need to use the .NET Framework 4.5 compatible Newtonsoft.Json.dll.

                  Using third-party resources such as Newtonsoft in NInjaScript would be outside of what our support could assist with or provide samples of. This is something you will need to diagnose and work through on your end. You can use third-party references in your own programming but this is something you would need to reference in the NinjaScript editor for it to work.

                  Let me know if you have further questions.
                  Brandon H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

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