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

passing sound file name from indicator properties dialog

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

    passing sound file name from indicator properties dialog

    i'm a little sketchy on how to pass a text string to PlaySound() from the Properties dialog - do i need to create a serialized string like i would for a ###ColorSerialize ?
    couldn't find an example - not sure what to look for....
    thanks

    - oh, i was hoping to just type the filename in next to its parameter name - like a number would be for period (number of bars) length...
    Last edited by stafe; 01-23-2020, 01:03 PM.

    #2
    Hello stafe,

    Thanks for your inquiry.

    Strings are serializable. You can follow the instruction below for adding additional user defined inputs. You can also right click on the Indicators folder in the NinjaScript Editor, select New Indicator, and add a user defined input there to have the New Indicator wizard generate the syntax.

    https://ninjatrader.com/support/help...d_input_pa.htm

    Also as a tip, you can add a file path picker for a more friendly way to select files.

    Code:
    [NinjaScriptProperty]
    [Display(Name="MyFilePath", Order=1, GroupName="Parameters")]
    [PropertyEditor("NinjaTrader.Gui.Tools.FilePathPicker", Filter="Any Files (*.*)|*.*", Title="Sound")]
    public string MyFilePath
    { get; set; }
    We look forward to assisting.
    Last edited by NinjaTrader_Jim; 03-21-2022, 07:54 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      omg, it took me forever to get back around to this because i was just plugging in the sound file without using the file picker you supplied above...
      but now i really do want to try to learn how to do this...

      so far i've tried the example as you gave to no luck
      Code:
      [NinjaScriptProperty]
      [Display(Name="Histo Divergence Signal Sound", GroupName="Plots", Order=52)]
      [PropertyEditor("NinjaTrader.Gui.Tools.FilePathPick er", Filter="Any Files (*.*)|*.*)", Title="Sound")]
      public string HistoDivergenceSound
      { get; set; }
      what i get is this folder with "file name" in the filename box and Any Files (*.*) in the suffix box with nothing but folders showing
      (there is an UI.xml file and a config.xml file but neither can be seen

      when i change the "Any Files (*.*)|*.*)" to "Any Files (*.wav)|*.*)"
      i get the correct folder for sound files C:\Program Files (x86)\NinjaTrader 8\sounds
      but there are no sound files showing even though there are 106 *.wav files in the folder including your default sound files...
      when i click the filename box arrow a blank box pops up and when i click the suffix box arrow only the *.wav will show
      so there's something not right with the syntax...

      i'm afraid you're just going to have to hold my hand here and tell me exactly what to do to make this picker work and pass the name of the sound file to the play sound argument...
      really sorry...

      here's the play sound syntax ... but i haven't been able to get there yet

      Code:
      if ( hDsignalsound )
      {
        PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\HistoDivergenceSound.wav");
      }
      the name of the sound file i'd like to play as the signal is "cymbals.wav" in the folder C:\Program Files (x86)\NinjaTrader 8\sounds

      thanks in advance
      /w

      Comment


        #4
        Hello stafe,

        Try setting up the filter as follows:

        Code:
        [NinjaScriptProperty]
        [Display(Name="MyFilePath", Order=1, GroupName="Parameters")]
        [PropertyEditor("NinjaTrader.Gui.Tools.FilePathPick er", Filter="Sound Files (*.wav)|*.wav", Title="Sound")]
        public string MyFilePath
        { get; set; }

        Then use PlaySound() when processing realtime data:

        Code:
        protected override void OnBarUpdate()
        {
            if (State == State.Historical)
                return;
        
            PlaySound(MyFilePath);
        }
        Note that sound files need to be PCM wav files. If the sound does not play, you could consider converting it using some open source conversion software, like Audacity.

        Publicly available link - https://www.audacityteam.org/
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Skifree, Today, 03:41 AM
        1 response
        2 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by usazencort, Today, 01:16 AM
        0 responses
        1 view
        0 likes
        Last Post usazencort  
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        603 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        23 views
        0 likes
        Last Post xiinteractive  
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        23 views
        0 likes
        Last Post Pattontje  
        Working...
        X