Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding alerts to indicator drawing

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

    Adding alerts to indicator drawing

    hello

    I have an indiicator that prints certain drawing objects - arrow etc when certain things occur
    i would like to add a visual screen flash and audio alert when these drawings appear

    can i paste the code here?

    Thankyou in advance

    #2
    Heres the code

    VALID HL APRIL 25.txt

    Comment


      #3
      Hello NISNOS69,

      It is possible to send an Alert to the Alerts Log window with a sound with the Alert() method.
      Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


      As far as flashing the screen, you could change the ChartControl.Properties.ChartBackground brush or you could open a new window.
      Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


      Comment


        #4
        Thankyou

        Where abouts in the code would I insert it?

        Thankyou

        Also how would I specify it on a candle close?
        Thankyou

        Comment


          #5
          Hello NISNOS69,

          If you are wanting to call Alert() when a drawing tool method is called, you can call the Alert() method one line above or one line below the Draw method.

          The script updates OnBarUpdate based on the Calculate setting. When set to OnBarClose, the logic is evaluated when the bar closes. When set to OnPriceChange or OnEachTick this will update before the bar closes. With these, require IsFirstTickOfBar to be true to trigger an action after a bar has closed.
          Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


          I am also including a link to a support article with helpful resources on getting started with C# and NinjaScript.

          Comment


            #6
            thankyou -

            Within this section of code?

            Code:
            {
                        int num1 = this.LowestBarFromRange(startIndex, barIndex);
                        this.bearishLows.Add(num1);
                        this.validHighs.Add(startIndex);
                        this.lowestLow = Low.GetValueAt(num1);
                        if(this.DebugMode) Print(string.Format("Yes, validated high @{0}", startIndex));
                        if(this.DebugMode) Print(string.Format("Resetting lowest low to {0}", this.lowestLow));
                        int num2 = this.HighestBarFromRange(this.validLows.LastOrDefault<int>(), barIndex);
                        int num3 = this.MarkSwingPeaks ? num2 : startIndex;
                        this.swingHighs.Add(num3);
                        if (this.ShowFractals)
                            Draw.ArrowDown(this, "valid-high-" + barIndex.ToString(), true, CurrentBar - num3, High.GetValueAt(num3) + (15 * TickSize), this.ValidHighColor);
                        if (!this.ShowSwings)
                          return;​
            I want the audio alert when the "arrow down" is drawn

            thankyou in advance

            Comment


              #7
              Hello NISNOS69,

              If the Draw.ArrowDown() call is the object in question, this is in a single statement block (no curly braces) and you would want to add curly braces for a multi-statement block and add the call to Alert() within the block.
              Code:
              if (this.ShowFractals)
              {
              Alert("myAlert", Priority.Low, "My Alert", NinjaTrader.Core.Globals.InstallDir+"\\sounds\\Alert1.wav", 10, Brushes.Black, Brushes.Yellow);
              Draw.ArrowDown(this, "valid-high-" + barIndex.ToString(), true, CurrentBar - num3, High.GetValueAt(num3) + (15 * TickSize), this.ValidHighColor);​
              }

              Comment


                #8
                NinjaTrader_ChelseaB

                APOLOGIES FOR THE DELAY -

                Thankyou - that helped me lots!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by abelsheila, 05-14-2025, 07:38 PM
                2 responses
                34 views
                0 likes
                Last Post hglover945  
                Started by nailz420, 05-14-2025, 09:14 AM
                1 response
                73 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
                0 responses
                353 views
                1 like
                Last Post NinjaTrader_Brett  
                Started by domjabs, 05-12-2025, 01:55 PM
                2 responses
                67 views
                0 likes
                Last Post domjabs
                by domjabs
                 
                Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
                1 response
                87 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Working...
                X