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

Writing an Alert from an Indicator on the Chart itself ???

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

    Writing an Alert from an Indicator on the Chart itself ???

    Is there a way for an Indicator (that has an Audio Alert and Alert Panel Alert built into it) to also write the Alert on the Chart itself ???

    If so, do you have any suggestions on what functions or coding to use in order to be able to write the Alert on the chart (possibly, on the Top Left, Top Right, Bottom Left, Bottom Right or Center etc...) ???

    THANKS

    #2
    Hello JMCA,

    Yes, you can use the built in method DrawTextFixed() to draw at Top Left, Top Right, Bottom Left, Bottom Right or Center.

    Place the DrawTextFixed() statement in the same code block with your alerts.

    This alert is likely in an if condition, so if you'd like to remove the drawing object when the alert is no longer true, you could add an else clause and RemoveDrawingObject()

    Sample:

    Code:
     
    if (Close[0] > Open[0])
    {
    Alert("MyAlert0", Priority.High, "message", "soundlocation", 0, Color.White, Color.Black);
    DrawTextFixed("myTag", "This is some text. ", TextPosition.Center);
    }
     
    else
    RemoveDrawObject("myTag");
    Last edited by NinjaTrader_RyanM1; 07-14-2010, 03:07 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Manual Removal of Text String?

      Hi Ryan, Thanks for your response,

      This sounds o.k., but I want the Alert to Remain on the Chart Until I Remove it from the Chart, after I review the Alert for a possible Trade Setup. I think this can be accomplished with AllowRemovalOfDrawObjects? Is there a way to do this by just clicking on the Alert that was Printed on the Chart (instead of right clicking on the text, selecting Remove and clicking o.k.)?

      Is there better way to accomplish all of this?

      Also I don't know exactly how to code this with the DrawTextFixed or another method you may have. Thanks.

      Comment


        #4
        You can remove the else clause if you want to manage removal of your own drawing objects. It would still have to be removed programatically.

        The code is mostly complete. You would add to the Alert section of your indicator. You can see an overview on creating your own custom indicator here. The code I shared should go into the OnBarUpdate()

        My suggestion is useful if you are comfortable editing indicators and copy - pasting. Unfortunately, I'm not aware of a non-programming solution for you. If you'd like more assistance in developing your own custom indicators, you might consider hiring a 3rd party NinjaScript consultant.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Thanks For All Your Help!

          I want to clear up my last response.

          I understand your "Original" Code (1st reply) and if I use it Without the else clause, Will I be able to remove (Manually Delete) the Printed Alert on the Chart itself (Yes or No)?

          IF NO Would the AllowRemovalOfDrawObjects = "True" (Function/Command) allow me to Manually Delete the Printed Alert, when used in your "Original" Code (1st reply) (Like the same way you would remove a line that was manually drawn on a chart)?

          IF this is Correct, How (Where) would I use this Function AllowRemovalOfDrawObjects in your Original Code (1st reply)?

          THANKS Again For Your Support !!!

          Comment


            #6
            Correct, you would need to allow the manual removal of programmatically drawn objects then in the Initialize() method fo your script -

            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi,

              I Did The Following, and I can't Delete the Alert on the Chart that was created by the DrawTextFixed Function. I tried clicking on it (No Delete Options), I tried Right clicking on the Chart and selecting Drawing Tools_Remove Drawing Objects "Select All" o.k. (Still Visible). Is there something else that has to be Done or Coded to be able to delete the Alert that was created by the DrawTextFixed Function. For your additional information this Indicator Alerts me Audibly and Visually (on the chart) when Price Hits the LinReg Line.

              Thanks.


              /// This method is used to configure the indicator and is called once before any bar data is loaded.
              ///</summary>
              protectedoverridevoid Initialize()
              {
              Add(
              new Plot(Color.Orange, "LinReg"));


              Overlay =
              true;
              AllowRemovalOfDrawObjects =
              true ;


              textFont =
              new Font( fontName, fontSize ) ;
              }

              Comment


                #8
                Unfortunately DrawTextFixed cannot be manually manipulated after being placed with code. All removal must be done programatically.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_RyanM View Post
                  Unfortunately DrawTextFixed cannot be manually manipulated after being placed with code. All removal must be done programatically.
                  Could a different indicator be started with code included to remove a specific drawtextfixed that was written to the chart by the strategy? And then remove the indicator and the drawtextfixed would stay removed? OR will that restart the strategy?

                  Just a thought,
                  Jon

                  Comment


                    #10
                    Hi Trader.Jon,

                    This wouldn't work. The tag for the draw object is not unique throughout the program, only the particular strategy or indicator instance it belongs with.

                    If you had one indicator that drawed line "a", this line "a" cannot be removed from a separate indicator with the RemoveDrawObject("a"); statement.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Ryan,

                      That is a shame ... would be very useful if it could be done ..
                      Not that I am a programmer, but could that be accomplished from the .NET framework?

                      JOn

                      Comment


                        #12
                        Hi Jon,

                        Unfortunatley this is beyond our scope of support.

                        For the original post: Drawing on the chart when an alert is true and then manually removing it should be possible. However, not with DrawTextFixed. DrawText() should work, but there's a little more involved with the positioning of the text, and additional programming may be needed so that the code isn't continuously trying to draw the object when you'd like to manually adjust.

                        The snippet below (for version 7 only) can unlock all drawing objects for manual adjustment:

                        foreach
                        (IDrawObject draw in DrawObjects)
                        {
                        // Unlocks all draw objects for manual manipulation on the chart
                        draw.Locked = false;
                        }


                        Ryan M.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by James650, 05-07-2024, 08:25 AM
                        3 responses
                        14 views
                        0 likes
                        Last Post NinjaTrader_ChristopherJ  
                        Started by xepher101, 05-10-2024, 12:19 PM
                        5 responses
                        67 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by Vitamite, Yesterday, 12:48 PM
                        3 responses
                        18 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by aligator, Today, 02:17 PM
                        0 responses
                        17 views
                        0 likes
                        Last Post aligator  
                        Started by lorem, 04-25-2024, 09:18 AM
                        22 responses
                        96 views
                        0 likes
                        Last Post lorem
                        by lorem
                         
                        Working...
                        X