• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Identifying when an Indicator has drawn a line

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

    Identifying when an Indicator has drawn a line

    I am using an indicator that identifies divergence by drawing a line in an indicator. I would like to use the fact that the line has been drawn as one of the variables in a strategy. Is there any way to identify a new line drawn in the plot of an indicator and to check for it at the close of each candle?

    Thanks

    #2
    Hello cpabiz20k,

    Thanks for your post.

    Yes, you can detect script drawn lines/objects as well as manually drawn lines/objects.

    As a starting point, please see the examples in the help guide page here: https://ninjatrader.com/support/help...rawobjects.htm

    Here is another thread that covers searching for objects and pulling the data from them.https://ninjatrader.com/support/foru...he-current-bar
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      So that is very helpful - thanks.

      I can see the drawing object and the indicator gives it a tag of 1927s - it looks like every time it draws something in the space the tag always ends in an "s". I think what I want to do is read the list of drawing objects and find one with a tag that ends in S that has the same end time as the last candle. Any tips on how to construct that?
      Thanks

      Comment


        #4
        Hello cpabiz20k,

        Thanks for your reply.

        If I understand correctly, you are saying that the indicator draws a line and give it the same tag of 1927s each time it draws the line. If that is correct then that would mean that it is erasing the previous object with the same tag name. If, on the other hand, they are drawing unique objects with different names to keep the historical lines then you could likely just check to see if the drawobject count has changed.

        Otherwise you would have do some C# string processing on the tag name to see that the last character is an "s" and is of the specified draw.Line type. You can do an internet search for this, here is an example of such a search: https://www.completecsharptutorial.c...g-function.php

        Once the draw object is found then you could have to create a copy of it to then check the end time of the line (assuming they are drawing it from oldest bar to newest bar) as I showed in the thread I referenced in my initial reply.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          This has been very helpful but after a lot of trial and error and searching for a specific example I am not able to get this to work. In the code example provided above I am having trouble looking only at objects where draw.Tag ends in "s". I hate to ask for such specific help but I can't seem to get the Endswith portion of the code to work, even if I convert draw.tag to a string and use the string in the logic. The tags I am looking for all end in "s" and they are numbered one greater than the previous. Any direction you can give is appreciated. Thanks.

          Comment


            #6
            Hello cpabiz20k,

            Thanks for your reply.

            For the tag name you could use some thing like: if (draw.Tag.EndsWith("s", StringComparison.CurrentCultureIgnoreCase))

            If you would like an indicator/script created for you, an alternative would be to hire a 3rd party programmer with Ninjascript experience. We can provide a link to such programmers in the NinjaTrader ecosystem if this would be of interest.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DTSSTS, Yesterday, 10:14 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by fredfred, Today, 04:17 PM
            0 responses
            10 views
            0 likes
            Last Post fredfred  
            Started by p.lozanski, Today, 03:51 PM
            0 responses
            7 views
            0 likes
            Last Post p.lozanski  
            Started by JTizz, Yesterday, 04:56 PM
            1 response
            25 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by brunoviveiros, Yesterday, 09:10 AM
            2 responses
            11 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X