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

How to add sound alert file directory?

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

    How to add sound alert file directory?

    Hi

    I'm stuck in my code. I would like to add sound alert file directory and not sure how.

    Thanks

    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class VolEnglfV1 : Indicator
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "Englf_Volume"));
    Add(new Plot(new Pen(Color.Gray, 2), PlotStyle.Bar, "Volume"));
    Add(new Line(Color.DarkGray, 0, "Zero line"));
    CalculateOnBarClose = false;
    }
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CurrentBar<3)
    return;

    if (Volume[0] > Volume[1])
    {
    Values[0].Set(Volume[0]);
    Values[1].Reset();
    {PlaySound("Alert1.wav");}
    }
    else
    {
    Values[1].Set(Volume[0]);
    Values[0].Reset();
    }
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }

    #endregion
    }
    }

    #2
    Hello wxtrox7,
    Welcome to the forum and I am happy to assist you.

    If the sound files are in the default sound folder then you can simply append the file name.
    Code:
    PlaySound("Alert1.wav");
    However if the sound files are located on a folder other than the default sound folder location then you have to specify the complete path. For example if the files are located in the C:\ drive then you have to append the following code.
    Code:
    PlaySound("C:\Alert1.wav");

    If you are trying to access it via the parameters dialog then you have to further custom code it and define a custom input parameter
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks

      Yes I was looking to add sound file directory via parameters. Any tips on how to approach it?

      Comment


        #4
        Hello wxtrox7,
        You can simply create a string parameter for it.

        Code:
        //in variable
        string soundFile = "Alert1.wav";
        
        //in OnBarUpdate
        PlaySound(soundFile);
        
        //in Properties
        [Description("Numbers of bars used for calculations")]
        [GridCategory("Parameters")]
        public string SoundFile
        {
          get{return soundFile;}
          set{soundFile = value;}
        }
        You can further custom code and create your own attribute settings however nothing we would support. You can however refer here to know more
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Thank you

          That worked

          Comment


            #6
            Originally posted by wxtrox7 View Post
            Thanks

            Yes I was looking to add sound file directory via parameters. Any tips on how to approach it?
            These 2 threads that I reference should tell you all that you need.

            ref: http://www.ninjatrader.com/support/f...43123#poststop
            http://www.ninjatrader.com/support/f...43401#poststop

            Comment


              #7
              When using JoyDeep's code, I notice it kept reusing the file name in the source and not the file name in the indicator's parameter window. Is this a bug?

              Comment


                #8
                Hello wxtrox7,
                To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

                Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

                I look forward to assisting you further.

                *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Jonafare, 12-06-2012, 03:48 PM
                5 responses
                3,986 views
                0 likes
                Last Post rene69851  
                Started by Fitspressorest, Today, 01:38 PM
                0 responses
                2 views
                0 likes
                Last Post Fitspressorest  
                Started by Jonker, Today, 01:19 PM
                0 responses
                2 views
                0 likes
                Last Post Jonker
                by Jonker
                 
                Started by futtrader, Today, 01:16 PM
                0 responses
                8 views
                0 likes
                Last Post futtrader  
                Started by Segwin, 05-07-2018, 02:15 PM
                14 responses
                1,792 views
                0 likes
                Last Post aligator  
                Working...
                X