Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Tools -> Alert -> not sent if the chart is not visible

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

    Drawing Tools -> Alert -> not sent if the chart is not visible

    Hi,

    I'm trying to create a DrawingTool as a Line which sends me an Alert when the price crosses it.
    I have programmed it under "OnRender".

    If I have the chart visible, it works.

    The problem is, when I have another Chart (from the same window) visible. It seems, as the chart where I have the alert is not visible, it will not be rendered every 250 msecs?
    And thus it cannot send any alert.

    Which is the solution?

    Thanks!

    #2
    Hello artson,

    This might be something better accomplished with an indicator, with the logic to trigger alerts not in OnRender().



    With a drawing tool, there is not an option to prevent suspension when inactive.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,

      I'm trying to implement a solution like here:


      I have managed to get the information from my "line":
      Tag, IsUserDrawn, DisplayName, SupportsAlerts

      But when I try to get the Price ( myline.StartAnchor.Price.ToString()) I do get the error "Object reference not set to an instance of an object."
      That means, I'm trying to get the price before it was created??, but how can it be, if I do get all other prperties frim this line?

      Comment


        #4
        Hello artson,

        The forum thread you have linked has an example that is an indicator. And getting this information in OnBarUpdate()...

        Are you making a custom drawing object?

        Or an indicator that loops through the drawing objects and can alert when the price is approaching a drawn object?

        'Object reference not set to an instance of an object' means that a variable is null and does not have an object assigned.

        Where myline assigned an object?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi, sorry,

          First I tried to this with a drawing tool, but as you explained to me, that it wouldn't work when inactive, I'm trying it inside an indicator with a loop throught the drawn objects

          I have copied it:

          foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)
          {
          if(thisObject is NinjaTrader.NinjaScript.DrawingTools.RegressionCha nnel)
          {
          RC = thisObject as NinjaTrader.NinjaScript.DrawingTools.RegressionCha nnel;
          Print(RC.StartAnchor.Price.ToString());
          Print(RC.EndAnchor.Price.ToString());
          }
          }

          And I become ths error.
          Could it have something to do with ploting an indicator bellow?

          As I mentioned, printig another characteristic from myline is no problem and it works, but the error comes when trying to get the price from the StartAnchor from myline
          I checked and the drawingtool "myline" has a StartAnchor with this name (in case the program is searching for an Anchor with this "name"...).
          Could the error be there?, in trying to get the information from the Anchors of my DwgTool?

          Comment


            #6
            Hello artson,

            The example code you have posted shows the assignment of the RC variable.
            Code:
            RC = thisObject as NinjaTrader.NinjaScript.DrawingTools.RegressionChannel;
            Where is the myline variable, the one that has a null object, assigned an object?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Sorry, here I am

              The exact code is:

              NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea RC;
              foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)
              {
              if(thisObject is NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea)
              {
              RC = thisObject as NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea;

              Print(RC.StartAnchor.Price.ToString());

              }

              }

              with my dwgtool being "EnviarALERTALinea"

              Comment


                #8
                Hello artson,

                The issue may be that you are copying code from one script and not addressing the existing errors in the script.

                You have stated:
                But when I try to get the Price ( myline.StartAnchor.Price.ToString()) I do get the error "Object reference not set to an instance of an object."
                That means, I'm trying to get the price before it was created??, but how can it be, if I do get all other prperties frim this line?
                myline is the variable that you should be focused on as this is the variable that is null and causing an error.

                Currently, you are focused on the RC variable, which is not causing an error.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Ok, sorry, I confused you

                  Take the las code as the real one.
                  My dwgtool is "EnviarALERTALinea" (forget "myline")


                  This code gives me the error:

                  NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea RC;
                  foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)
                  {
                  if(thisObject is NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea)
                  {
                  RC = thisObject as NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea;

                  Print(RC.StartAnchor.Price.ToString());
                  }
                  }

                  If I delete the "Print" instruction with the "Price" it gives me error.



                  In this I have no error:

                  NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea RC;
                  foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)
                  {
                  if(thisObject is NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea)
                  {
                  RC = thisObject as NinjaTrader.NinjaScript.DrawingTools.EnviarALERTAL inea;

                  }
                  }

                  Comment


                    #10
                    Hello artson,

                    Is the RC object null?

                    if (RC == null)
                    {
                    Print("RC is null");
                    }

                    Does EnviarALERTALinea have a StartAnchor?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes, it prints RC is null

                      The EnviarALERTALinea has a StartAnchor:

                      StartAnchor = new ChartAnchor { IsEditing = true, DrawingTool = this };

                      Comment


                        #12
                        Hello artson,

                        Does this only occur with EnviarALERTALinea or does this also occur with a regular line object?

                        If this only occurs with EnviarALERTALinea, there may be something with that script that is not allowing the casting.

                        If this is occurring with Line, there may be code that has not be provided causing an issue.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          I get it also with "Line"....

                          But I have to check it carefully...

                          Thanks!

                          Comment


                            #14
                            Hello artson,

                            To assist I have copied and pasted the example from the help guide into an indicator.


                            Note that you should draw the object before adding the instance of the indicator. The DrawObjects collection will be empty when reloading the script, so you could wait for a real-time bar to close, or remove the instance or add a new instance.
                            Attached Files
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks,

                              And how could I print the price of the "StartAnchor"?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by PhillT, Today, 02:16 PM
                              2 responses
                              6 views
                              0 likes
                              Last Post PhillT
                              by PhillT
                               
                              Started by Kaledus, Today, 01:29 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by frankthearm, Yesterday, 09:08 AM
                              14 responses
                              47 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by gentlebenthebear, Today, 01:30 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post gentlebenthebear  
                              Started by PaulMohn, Today, 12:36 PM
                              2 responses
                              17 views
                              0 likes
                              Last Post PaulMohn  
                              Working...
                              X