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

Path variable for \Documents\NinjaTrader 8 location

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

    Path variable for \Documents\NinjaTrader 8 location

    I want to export custom sound files with my indicator. I understand how to add them to the exported .zip file but my question is, the full path to the NinjaTrader 8 folder under Documents is different on other PC's. What can I use for a path in the PlaySound statement in my code? Is there a NinjaTrader.Core.Globals statement for the Documents install location? I did try PlaySound(@"%userprofile%\Documents\NinjaTrader 8\... but it doesn't work Thanks

    #2
    Hello mlarocco,

    Thanks for writing in.

    There are no supported NinjaTrader.Core.Globals statement for accessing the Documents folder. The specific file path would need to be hardcoded in your script

    You can obtain the default NinjaTrader installation directory to access the sounds folder by using NinjaTrader.Core.Globals.InstallDir property. An example of this could be seen on the PlaySound help guide page linked below.



    We are tracking interest in a current feature request ticket for the ability to supply the default location of custom sounds. I have submitted your vote to SFT-1652.

    As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

    Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Here is a code bite work-around I use.

      private string strSoundfile_Buy;
      private const string strcSoundFile_Alert2 = @"\sounds\Alert2.wav";
      ..
      ..
      else if (State == State.DataLoaded)
      {
      strSoundfile_Buy = NinjaTrader.Core.Globals.InstallDir + strcSoundFile_Buy;
      }

      Define a string to use in an Alert or Playsound. Then initialize it in State.DataLoaded event... and use from that point forward.

      Cheers

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        Hello mlarocco,

        Thanks for writing in.

        There are no supported NinjaTrader.Core.Globals statement for accessing the Documents folder. The specific file path would need to be hardcoded in your script

        You can obtain the default NinjaTrader installation directory to access the sounds folder by using NinjaTrader.Core.Globals.InstallDir property. An example of this could be seen on the PlaySound help guide page linked below.



        We are tracking interest in a current feature request ticket for the ability to supply the default location of custom sounds. I have submitted your vote to SFT-1652.

        As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

        Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

        Please let me know if I may assist further.
        After I posted this I found I can use "PlaySound(NinjaTrader.Core.Globals.UserDataDir + @"\templates\BA5minGold\Cancel Order.wav");" and it seems to work fine. Does this make sense?

        Thanks

        Comment


          #5
          Hello mlarocco,

          Thanks for your note.

          This is not documented in the help guide but if it is working for you then yes, you could likely use that when calling the PlaySound() method in your script.

          Please let me know if I may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          30 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          943 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          9 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          4 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          28 views
          0 likes
          Last Post wzgy0920  
          Working...
          X