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

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.


            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 ghoul, Today, 06:02 PM
                3 responses
                13 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                44 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                20 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                180 views
                0 likes
                Last Post jeronymite  
                Started by DanielSanMartin, Yesterday, 02:37 PM
                2 responses
                13 views
                0 likes
                Last Post DanielSanMartin  
                Working...
                X