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 adeelshahzad, Today, 03:54 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          7 responses
          32 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by merzo, 06-25-2023, 02:19 AM
          10 responses
          823 views
          1 like
          Last Post NinjaTrader_ChristopherJ  
          Started by frankthearm, Today, 09:08 AM
          5 responses
          22 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          43 views
          0 likes
          Last Post jeronymite  
          Working...
          X