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

Line Alerts Absence driving me nuts

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

    Line Alerts Absence driving me nuts

    Can anyone help with this I am sure it would be useful to a lot of people.
    In many trading packages you can draw a line, right click and add an alert. I had asked and expected that this basic facility would be available in NT7 but it looks from forum comments that it will not.

    I see someone has coded a Price Alert in the indicators. Using this as a base I would like to amend it so that in the indicator options box there is a facility for selecting a number of sound files. Therefore although I will have to select indicators etc to bring up the price alert indicator at least I can quickly input the price level and select a sound file from a drop down box.

    If someone can put up an example for this, I would be able to amend the
    ninjascript to add the required files to be selected.

    Incidentially is there a quick way to change from one workspace to another, rather than control panel, file, workspaces etc. Many packages allow a tab to be clicked on. Perhaps this is something that could be included in Ninja 7.5!

    Thanks

    #2
    MicroAl,

    Unfortunately creating a dropdown menu for you to select sound files is beyond the level of support we can offer. This should be doable through C# though. Perhaps you can try searching MSDN or google for creating enum types.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Price Alert Modified

      Maybe I should have been clearer. I am only looking for a number of selections that can be made from an indicator menu. Ie I believe in the
      MultiSlope indicator, you can select a number of types of EMA's surely it is possible to do this, to select a number of sound files, even if you have to use aliases in the indicator menu for the sound file.

      Ie in an indicator say there is a line

      if price above x then play sound file C:\1000tick.wav

      all I want to do is have a parameter box etc in the indicator with a number
      of selections eg 1, 2, 3, 4, 5

      then in the indicator coding

      if parameter 1 selected then playsound c:\1000.tick.wav
      if parameter 2 selected then playsound c:\1200.tick.wav

      etc

      Surely its only a matter of getting different lines of code to execute relative to the parameter being selected.

      I realise I will have to code the lines in ninjascript to tell ninja where the appropriate sound files. I just wondered if someone had a quick example to save me spending a day looking through the manuals etc

      Comment


        #4
        Just create yourself an integer parameter then. You can see any of the prebuilt indicators for how to do this. Look at SMA's Period parameter for instance. Pay attention to the Variables and Properties region of the code.

        Then in your PriceAlert code just have if-else statements.

        Code:
        if (myVariable == 1)
             Alert(....sound1.wav);
        else if (myVariable == 2)
             Alert(....sound2.wav);
        etc.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Price Alert Modified

          Thanks Josh

          A nice quick reply from the Ninja Team as usual!

          Regards

          Comment


            #6
            Price Alert only sounding once

            I have now modified the Price Alert Indicator to give me a drop down box where I can select a sound file. This is working fine but the alert is only sounding once. I have set the rearm period to 10 seconds but do I need a loop or something in the following code? I want the alert to sound everytime the price point is crossed. This is the code in onbarupdate

            protectedoverridevoid OnBarUpdate()
            {
            if (ShowTriggerLine)
            Values[0].Set(Price);
            if (Historical || triggered)
            return;
            elseif (!triggerSet)
            {
            triggerOnGreaterThan = Close[0] >= price - (TickSize * 0.5) ? false : true;
            triggerSet = true;
            }
            if ((triggerOnGreaterThan && Close[0] >= Price - (TickSize * 0.5)) || (!triggerOnGreaterThan && Close[0] <= Price + (TickSize * 0.5)))
            {
            triggered = true;

            switch (MySoundType)
            {
            case SoundEffect.Tick800 :
            Alert(DateTime.Now.Millisecond.ToString(), NinjaTrader.Cbi.Priority.Medium, "Price level '" + Price + "' hit!", Cbi.Core.InstallDir + @"\sounds\Tick800.wav", 10, Color.Yellow, Color.Black);
            break;

            case SoundEffect.Tick1000 :
            Alert(DateTime.Now.Millisecond.ToString(), NinjaTrader.Cbi.Priority.Medium, "Price level '" + Price + "' hit!", Cbi.Core.InstallDir + @"\sounds\Tick1000.wav", 10, Color.Yellow, Color.Black);
            break;

            }

            }
            }

            Comment


              #7
              Originally posted by MicroAl View Post
              I have now modified the Price Alert Indicator to give me a drop down box where I can select a sound file. This is working fine but the alert is only sounding once. I have set the rearm period to 10 seconds but do I need a loop or something in the following code? I want the alert to sound everytime the price point is crossed. This is the code in onbarupdate

              }

              You may want to consider a creating a variable lastTriggerTime and then do a check for Current Time > lastTriggerTime + 10 seconds. Then reset the lastTriggerTime to Current Time when conditions evaluate to true.

              Comment


                #8
                Price Alert only sounding once

                Thanks I will look into that. I presume from your answer that the code I pasted below is only designed to fire once. I thought it would check every tick, it this is set.

                Comment


                  #9
                  Depends on your CalculateOnBarClose setting. If set to false then it will process the OnBarUpdate() method on every tick, otherwise, just once per bar.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Josh

                    I am confused here. I have set Calculate on Barclose to false, but the alert only fires once. I thought it would check on every tick and then rearm after 10 seconds?

                    Thanks

                    Comment


                      #11
                      If you feel it only triggers once you need to step through your code and debug it. Add Print() and walk through each step to see if you actually are calling Alert() again.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Any chance you can post the code as to how to:

                        "...give me a drop down box where I can select a sound file."

                        thanks

                        Comment


                          #13
                          Drop down box for sound file selection

                          No problem, I am not on my main computer at the moment but hope to do it tomorrow. Just used a enumeration and switch and case statements
                          to select the right file.

                          Comment


                            #14
                            Selecting a Sound File

                            Ok this is how I modified an indicator to select a sound file. I created the following enumeration and placed in under the using declarations line

                            +Using declarations
                            public enum SoundEffect
                            {
                            SoundFile1,
                            SoundFile2

                            }

                            in the OnBarUpdate Method I used a switch statement to select the sound file required eg

                            switch (MySoundType)

                            {

                            case SoundEffect.SoundFile1 :
                            (What you wish to do here eg Alert statement etc)
                            break;

                            case SoundEffect.SoundFile2 :
                            (What you wish to do here eg Alert statement etc)
                            break;
                            }

                            To create the drop down box in the region Properties section goes

                            [Description("Sound Required")]
                            [Category("Parameters")]
                            public SoundEffect MySoundType
                            {
                            get { return mySoundType; }
                            set { mySoundType = value; }
                            }

                            I am sure there are probably better ways to achieve this. I am not a professional programmer. In my modified indicator I have a selection of about 10 sound files, but it means 10 case statements that the computer
                            has to run through on every tick. However it does not seem to affect the running of the program.

                            Hope This Helps



                            Last edited by MicroAl; 03-08-2009, 01:51 PM. Reason: Typographical Error

                            Comment


                              #15
                              Thanks for sharing, appreciate the code

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ender_wiggum, Today, 09:50 AM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by rajendrasubedi2023, Today, 09:50 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by geotrades1, Today, 10:02 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post geotrades1  
                              Started by bmartz, Today, 09:30 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by geddyisodin, Today, 05:20 AM
                              3 responses
                              25 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X