Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Looping through a list

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

    Looping through a list

    Hello,

    how can one loop through a list to see if the current price/high is part of the drawing tag string of the drawing object to remove this drawing object.

    Thank you!
    Tony

    #2
    Hello tonynt,

    You can find some examples of using loops in C# in the following link: https://docs.microsoft.com/en-us/dot...epts/iterators

    There are some samples of comparing strings in the following link: https://docs.microsoft.com/en-us/dot...ompare-strings

    You would likely need to edit out the tag from the string while you are comparing strings to gather the price value you added to the tag, you can convert strings to numbers if necessary as well. These are all C# concepts that would not be documented for NinjaScript. You can find samples or documentations for these topics by using MSDN or google.

    Please let me know if I may be of additional assistance.

    Comment


      #3
      Hello,

      thank you for your reply and the links. Going through this I have no idea what this console stuff means.

      I´d need to remove drawing object referring to the high and not currentbar as there is in an example with
      for (int i = 0; i < myList.Count; i++)
      {
      if (i < 10)
      {myList.Remove(myList[i]);
      RemoveDrawObject("mydot");
      Print ("Event # "+ i + " Occured on bar: " + myList[i]);}}
      or
      for (int i = myList.Count -1; i >= 0; i--)
      {
      Print ("Event # "+ i + " Occured on bar: " + myList[i]);

      if (i < myList.Count - 10)
      {
      RemoveDrawObject("mydot" + myList[i].ToString());
      myList.Remove(myList[i]);}
      }
      Instead of the "logic" of removing a drawing object referring to a barnumber I would need to remove the drawing object when the high[0] is same as the High[0] in one of the drawing object tagged with Draw.Line(this, "tag1"+CurrentBar, false, 0, Highs[1][0], -100, Highs[1][0], Brushes.Red, DashStyleHelper.Dash, 2);

      Thank you!
      Tony

      Comment


        #4
        Hello tonynt,

        Going through this I have no idea what this console stuff means.
        The samples from MSDN or other sources rely on you having learned C#, you can use MSDN's learning section to learn C#: https://dotnet.microsoft.com/learn/csharp

        Instead of the "logic" of removing a drawing object referring to a barnumber I would need to remove the drawing object when the high[0] is same as the High[0] in one of the drawing object tagged with Draw.Line(this, "tag1"+CurrentBar, false, 0, Highs[1][0], -100, Highs[1][0], Brushes.Red, DashStyleHelper.Dash, 2);
        That is possible, what part are you needing assistance with? What have you tried?



        Please let me know if I may be of additional assistance.

        Comment


          #5
          Jesse,

          I have all I need after years of coding and learning by doing. I would need only now wo store the string with high[0] of a ray and then to loop through the list and remove the draw object when current/last high[0] matches with one of the "tagX+High[0].ToString. so that this drawing tool is removed. I´m asking this for days and weeks and get snippets with remove of drawing object by barnumber or whatever that makes no sense. Why should a swing or high or certain price be removed after x number of bars. And from this sample I can not derive how it works with useing the draw..."tag"+High[0] instead of "tag"+Currentbar. The drawing is no problem at all, its about remove that drawing tool when high matches with this high in the list.

          I do not understand the samples in the links with console. I have no more power to learn this when I need maybe 5 lines of code. I see in the forum accurate replies to questions (I also had in the past for which I thank you all) but with this question I only get replies that might work for a programmer. I will not learn C## (no, I can not learn anymore...) because I need 5 lines of code to finish this.

          Thank you!
          Tony

          Comment


            #6
            Hello tonynt,

            I have all I need after years of coding and learning by doing. I would need only now wo store the string with high[0] of a ray and then to loop through the list and remove the draw object when current/last high[0] matches with one of the "tagX+High[0].ToString. so that this drawing tool is removed. I´m asking this for days and weeks and get snippets with remove of drawing object by barnumber or whatever that makes no sense.
            If you have been having trouble for a while on this problem you potentially need to reduce the problem to a more simple question. Our support is not here to make custom scripts or samples for you, the purpose of this forum is to help link you to resources so you can use them to learn on your own. If you need a more hands on approach please seek an outside developer.

            Why should a swing or high or certain price be removed after x number of bars. And from this sample I can not derive how it works with useing the draw..."tag"+High[0] instead of "tag"+Currentbar. The drawing is no problem at all, its about remove that drawing tool when high matches with this high in the list.
            Working with strings or lists are outside of the scope of our support, you are working with C# types. If you need to understand these concepts better please use C# resources to learn about them.

            I do not understand the samples in the links with console.
            If you don't understand something about a resource that was linked to you can just ask about that directly. Console is a concept which is explained in the MSDN documentation, that is the basic way to run a C# program.


            I have no more power to learn this when I need maybe 5 lines of code. I see in the forum accurate replies to questions (I also had in the past for which I thank you all) but with this question I only get replies that might work for a programmer. I will not learn C## (no, I can not learn anymore...) because I need 5 lines of code to finish this.
            I understand that we could make this and link a sample and we have done that in the past, however that would be at our digression and only if we feel it will help you learn the concept. Based on our previous discussions and also this one I don't feel providing an exact code solution will help you learn. You have also said you do not want to learn C# so there is no reason we should be providing a code sample here, you should seek an outside developer in that situation where you don't want to code it yourself.


            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            649 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X