Announcement

Collapse
No announcement yet.

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.

    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/

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X