• 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

working with doubles from a list for conditions and drawings

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

    working with doubles from a list for conditions and drawings

    Hello,

    I have finished a code with horizontal lines at the high of bars if conditions are met. I use "same_name" + CurrentBar because we dont know how often it occurs, so I can not define "name1" "name2"....Everything works fine even historically. But I have 2 questions now please:
    a.) how do I add the doubles (High) to a list to work with, eg for entries when the line is touched again
    b.) how can I refer to the drawing objects to remove them when it is touched.

    I can do without problems when I use defined doubles and tagnames but here my problem is how to refer to "same_name" + CurrentBar to remove this line. I couldn´t get it even when trying for days now.

    Thank you!
    Tony

    #2
    Hello Tony,
    Thanks for your post.

    a.) how do I add the doubles (High) to a list to work with, eg for entries when the line is touched again
    If you want to store your line values in a series you can do that with a Series<t>. Please see the following help guide link for more information on working with Series<t> objects: https://ninjatrader.com/support/help...s/?seriest.htm

    b.) how can I refer to the drawing objects to remove them when it is touched.
    You can use RemoveDrawObject() to remove any unneeded draw objects: https://ninjatrader.com/support/help...drawobject.htm
    Are you wanting to remove everything except the most recent lines?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. I know how to remove all objects with RemoveDrawObjects(); and how to work with DrawObject ("abc");

      But the question was how to remove DrawObject("line" + CurrentBar) when it is touched by price. If it would be a tag with name "line" that occurs only one time then I could work with RemoveDrawObject("line") when price touches double "linevalue". But I can not store "linevalue + CurrentBar" and I can not RemoveDrawObjeckt("line + CurrentBar").

      Thank you!
      Tony

      Comment


        #4
        Tony,

        I would probably loop through the drawing objects on the chart and create some logic that removed the drawing objects I no longer wanted.

        What are you currently trying that is not working? Can you show us a snippet of what you have been working on?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          thank you for your reply. I dont want you doing coding for me. I´m asking only how one can refer to drawing objects that are built with "Draw.Line("same name as other drawing objcect" + CurrentBar....) to remove them when all drawing objects are called ""same name as other drawing objects" +CurrentBar"


          Thank you!
          Tony

          Comment


            #6
            Tony,

            You will need to either (A) use only a single drawing object, (B) know how many draw objects you need, or (C) create some custom logic that tracks the "tag" for the specific drawing objects you want to remove.

            If you elect to go (C), I stick by what I said. I recommend looping through the Drawing Objects and checking their tags for the ones you want to remove. Take a look at this help guide document for any easy way to work with drawing tools on your chart.
            https://ninjatrader.com/support/help...rawobjects.htm

            If there are two bars on the chart and there is a drawing object associated with both bars with the tag name of "tag"+CurrentBar there would be two different tag names. One will be "tag1" and the other will be "tag2". You will need to reference the specific "tag"+CurrentBar value you want to remove.

            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              thank you for your reply. (A) and (B) is clear and I do for years.
              (C) is exactly what I´m tryinig to ask. I dont see from that link how one can access the bar with the drawing, sorry.

              Lets say there are 10 bars and on bar "no4" there is the Draw.Line("line" + currentBar. How do I catch this please?

              Thank you!
              Tony

              Comment


                #8
                Tony,

                There are three samples at that link of different ways you could go about this. The bottom sample demonstrates how to loop through the DrawingObject collection to find specific drawing objects and the top sample shows how to locate a Drawing Object by tag name. There will not be an easier sample.

                Lets say there are 10 bars and on bar "no4" there is the Draw.Line("line" + currentBar. How do I catch this please?
                If you want to remove a Draw.Line with "line"+CurrentBar as the tag name, and you are on bar number 4, you could use RemoveDrawObject("line4");
                Josh G.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by GLFX005, Today, 09:17 AM
                0 responses
                8 views
                0 likes
                Last Post GLFX005
                by GLFX005
                 
                Started by pjsmith, Today, 08:43 AM
                2 responses
                16 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by guillelagoria, Today, 07:26 AM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_ChristopherD  
                Started by aprendiz, Today, 08:06 AM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by faisamtrader, Yesterday, 10:03 PM
                3 responses
                21 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X