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

Soundfiles - need some help

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

    Soundfiles - need some help

    I built an indicator that kicks in with a drawn triangle on the chart and a sound file when a series of EMAs from different time frames are aligned. I want to run this in 8 different instruments with 8 different sound files and it's supposed to alert me with sound to then look at that instrument.

    All good and fine. The drawn triangles always show up but I have difficulty with the sound files. Sometimes it turns on, more often not.

    Looking at the 8 charts I seem to see that whenever a soundfile is being called at the same time by more than one instrument it seems to not play the sound file of either. When there is only one instrument's sound file being triggered in a given minute then it plays okay.

    What could cause this non-playing of the sound files and how could I address that?


    PS: I use the following line of code to activate the soundfile with "soundFilelong" and "str" (Seconds-to-ReArm) being user-definable:

    Alert("myAlert", NinjaTrader.Cbi.Priority.High, "My EMAs", soundFilelong, str, Color.Black, Color.Yellow);

    I use that Alert line code because I simply do not know how to use this one
    PlaySound(@"C:\mySound.wav");
    when I want to tell it also to use Seconds-to-ReArm.


    sandman

    #2
    Hi sandman, that's unfortunately a known limitation as there's no queuing of those files to be played if triggered exactly at the same time. One workaround idea would be looking into raising the alert from one 'master' indicator so you would know what triggered and could look into replaying via a timer for example, but that would mean some deeper custom coding then. We have this in our feedback lists to look into enhancing for the next major platform update, I have made sure to count your vote in as well.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand. Pity but thank you.

      I am trying to get away from having to constantly look at the screen so I have got to resolve it that a sound is generated somehow whenever the conditions are met.

      Could you tell me a bit more about the idea behind creating a master indicator.

      I also think it is possible to install my indicator in the Market Analyzer (though I have never worked with it yet). Could that make a difference?

      sandman

      Comment


        #4
        sandman, running through the MA would not make a difference. Though you might be able to visually better see the overall results then aligning. Currently when you run multiple instance you don't know which one triggered and in which order so your code could look into a queued playing of the sound, that would be the idea of the master study, I would not have sample here though.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Got it.

          I currently run this indicator in a 1-Minute chart. Let's say I would only deal with 4 instruments. Would it make a difference if I would change the first chart/instrument to a 58-Second chart, the next one to a 59-Second chart, third one to 60 Seconds, and a fourth one to 61-Seconds. Could that kind of set up deal better with triggers of sound alerts on 2 or more instruments?

          I can of course try this out but thought I'd run this by you to get your input based on your knowledge and experience.

          sandman

          Comment


            #6
            sandman, I think that's a good idea, however I'm not sure how it would change your signals (if it would) - that would need to be played with. Also it could be that you don't get a trade / tick update in that short period meaning the very similar series then also update roughly at the same time as the next trade is seen. Then it would need more spacing out in seconds difference, which in turn would impact signals produced likely more.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Okay. I will try out something different to see if that gives me what I want. I need one bit of guidance. Below is the code I am using. BarsArrays refer to 3, 5 and 15Minute time frames.

              My question concerns the first line with Close > Open. As written it refers to the primary data series which in my case as mentioned was the 1Minute Chart.

              How do I have to write that line to refer to the 5Min Data series?

              Like this Closes[2] > Opens[2][0]???

              sandman

              Here is the code I have:
              if (Close[0] > Open[0]
              && Close[0] > LinReg(9)[0]
              && (EMA(BarsArray[1],4))[0] > (EMA(BarsArray[1],7))[0]
              && (EMA(BarsArray[1],7))[0] > (EMA(BarsArray[1],13))[0]
              && Rising (LinReg(BarsArray[1],9))
              && (EMA(BarsArray[2],4))[0] > (EMA(BarsArray[2],7))[0]
              && (EMA(BarsArray[2],7))[0] > (EMA(BarsArray[2],13))[0]
              && Rising (LinReg(BarsArray[2],9))
              && (EMA(BarsArray[3],4))[0] > (EMA(BarsArray[3],7))[0]
              && (EMA(BarsArray[3],7))[0] > (EMA(BarsArray[3],13))[0]
              && Rising (LinReg(BarsArray[3],9)))

              {
              Alert("myAlert", NinjaTrader.Cbi.Priority.High, "My EMAs", soundFilelong, str, Color.Black, Color.Yellow);
              }




              sandman

              Comment


                #8
                Correct, that would expressed then as Closes[2][0] > Opens[2][0]
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Great Bertrand. Got it on the additional [0]. I think that will solve it because I then can add an additional BarsArray, for a user-definable time frame and I'll run that on all 8 instruments to see if my sound comes up at the right times on each instrument. Thanks for the help.

                  sandman

                  Comment


                    #10
                    Bertrand.

                    Thought I'd let you know that I think I have resolved my sound issue in full.

                    The Syntax for Alerts is:
                    Alert(string id, Priority priority, string message, string soundLocation, int rearmSeconds, Color backColor, Color foreColor)

                    Somewhere I read that the stringID must be unique. But as I had it in a generic indicator so to speak and being used simultaneously on several instruments, the stringID being the same across all instruments = problem!

                    I simply made this "stringID" userdefinable through the indicator menu. I can just type in whatever I want.

                    I have thus far run this for a day on a few different instruments. I had the Alerts window open to see when the Alert was triggered, and every time it appeared there, the sound also came on. And even if there was an Alert on 2 different instruments at the same time the soundfile (different for each) was activated for both.

                    I thought I'd let you know and in case it comes in handy for someone else.

                    sandman

                    Comment


                      #11
                      This is true, all alerts need a different ID to be seen and heard at the same time.
                      eDanny
                      NinjaTrader Ecosystem Vendor - Integrity Traders

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by wzgy0920, 04-20-2024, 06:09 PM
                      2 responses
                      26 views
                      0 likes
                      Last Post wzgy0920  
                      Started by wzgy0920, 02-22-2024, 01:11 AM
                      5 responses
                      32 views
                      0 likes
                      Last Post wzgy0920  
                      Started by wzgy0920, Yesterday, 09:53 PM
                      2 responses
                      49 views
                      0 likes
                      Last Post wzgy0920  
                      Started by Kensonprib, 04-28-2021, 10:11 AM
                      5 responses
                      191 views
                      0 likes
                      Last Post Hasadafa  
                      Started by GussJ, 03-04-2020, 03:11 PM
                      11 responses
                      3,230 views
                      0 likes
                      Last Post xiinteractive  
                      Working...
                      X