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

Cannot remove drawn rays when IsGlobal = true

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

    Cannot remove drawn rays when IsGlobal = true

    Hello,
    I have an indicator which draw some rays on a chart and remove them later.
    I noticed that when the rays are drawn with the parameter IsGlobal=true i cant remove them.
    Attached is a test indicator to demostrate the issue.
    The indicator draw 2 rays (a global one and a "local") using the default template and remove them some bar after.
    The global ray in not removed and stay on chart.
    Any clue about that?
    Attached Files

    #2
    Hello,
    I have also noticed that global ray is not present in DrawObjects collection.
    I have modified the test indicator to include printing of draw object's Tag
    Attached Files
    Last edited by aerofly; 06-14-2018, 07:22 AM.

    Comment


      #3
      Hello aerofly,

      Thanks for the post.

      The string in RemoveDrawObject("@RayTestGlobal>"); is not the same as "RayTestGlobal" in the test script that was posted.

      I was able to get global draw objects to delete with my test script using the proper string.

      Please let me know if you do not see the same thing after fixing the call to RemoveDrawObject.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Yes Chris,
        I was testing and the seconfd version posted has wrong string.
        Here is the right indicator which is still not working on my end.
        Please note also the missing of ray in DrawObjects collection
        Thak You
        Attached Files

        Comment


          #5
          Just to be precise removeobject doesn't work on my end both if i use "RayTestGlobal" or "@RayTestGlobal" indifferently

          Comment


            #6
            Hello aerofly,

            Thanks for the reply.

            The script must have the same tag string to know which object to remove. Double click on the string that should be removed but is not, it likely has a different tag string than "@RayTestGlobal>"

            The string must match exactly, so change your RemoveDrawObject to this:

            Code:
            RemoveDrawObject("RayTestGlobal");
            Then, remove the indicator from your chart, remove any drawing tools manually, then add the indicator back on and you will see the object being deleted.

            As for the object not showing up in the DrawObjects list, I will ask our product management team if that is expected or not.

            I look forward to assisting further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello Chris, I'm sorry there was a mistake in string.

              Now string are correct as You indicated but still no work.
              I have also added a RemoveDrawObjects() what should remove all rays but global one still stay on chart (see enclosed picture)

              I've enclosed the amended indicator that doesnt work on my end.
              I cant see what i am doing wrong.
              Please check if this work on your end.
              Attached Files

              Comment


                #8
                Hello aerofly,

                Thanks for the reply.

                I tested your new script and it worked as expected. If you are on a release greater than 8.0.14.x this will work for you as well. I did have to wait for the bar to close to see it happen. There is some extra logic in the script that is throwing off the results. I advise you make a more simple script to see that removing a global draw object will delete globally.

                Please let us know if we may be of any further assistance.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Chris,

                  sorry to bother You but this is the culprit

                  Originally posted by NinjaTrader_ChrisL View Post

                  I did have to wait for the bar to close to see it happen.
                  when the object is global then RemoveDrawObject works only if called at close of the last real time bar; it doesnt work if called on any other bar.

                  to clarify:

                  this works only in real time:
                  Code:
                  if (Time[0] == new DateTime(2018,6,14,15,45,0))
                  {
                      Draw.Ray(this, "RayTestGlobal", 50, High[50], 0, High[0], true, "");
                   }
                   if (Time[0] [SIZE=5][COLOR=Red]>=[/COLOR][/SIZE] new DateTime(2018,6,14,16,0,0,0))
                   {
                          RemoveDrawObject("RayTestGlobal");
                    }
                  This doesnt works even in real time
                  Code:
                  if (Time[0][SIZE=5] [COLOR=red]==[/COLOR][/SIZE] new DateTime(2018,6,14,16,0,0,0))
                  {
                     RemoveDrawObject("RayTestGlobal");
                  }

                  None of them works if disconnected from data feed

                  Comment


                    #10
                    Hello aerofly,

                    Thanks for the reply.

                    Edit:

                    I misread your previous post. Let me test this and I will let you know what I find.

                    Thanks in advance for your patience.
                    Last edited by NinjaTrader_ChrisL; 06-14-2018, 12:45 PM.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello aerofly,

                      Thanks for waiting.

                      This seems to be more of a logic and debugging problem. Have you added print statements throughout your script to see what kind of output you are getting and why some items are not becoming true when you expect them to?

                      I will look forward to your reply.
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Chris,

                        sorry if I take long to respond but we live in different time zones (I'm Italian).

                        Enclosed is a new version of demo indicator that i coded without using Time in conditions, to be sure that it works the same way for you too.

                        Enclosed are also a snapshot of the chart and content of output window.

                        As You can see the statements to draw and remove ray are surely executed but it remain on chart indifferently if in real time or offline from data feed.

                        Thanks for your help
                        Attached Files

                        Comment


                          #13
                          Hello Chris,

                          I've solved the puzzle.

                          It's a problem of syncronization probabily due to multithreading.

                          In fact if I put this statement
                          Thread.Sleep(1000)
                          before the RemoveDrawObject in my demo indicator
                          then all works right and the ray is removed.
                          If i remove the sleep time then the ray remain on chart.


                          I thought about this reading this note on help guide about DrawObjects
                          When reloading NinjaScript, all objects (including manual drawing tools) are reloaded at the same time. There is no guarantee a manually drawn object will be added to the DrawObjects collection before an indicator starts processing data.
                          It seems true even for draw objects drawn by an indicator

                          Comment


                            #14
                            Hello Chris,

                            as a ending note it seems that my problem is in someway related to this (item 1)



                            I see that it was reported as solved in 8.0.0.3 beta but maybe there is some side effect still in place or maybe is possible a regression

                            Please let me know if You have any news

                            Thank You so much

                            Comment


                              #15
                              Hello aerofly,

                              Thank you for the reply.

                              The release notes claim there was an exception when trying to use RemoveDrawObjects(). We are not seeing that here but if you are experiencing some sort of unexpected behavior please let me know with the steps to reproduce.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              12 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X