Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling Draw Arrow

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

    Calling Draw Arrow

    If I store the CurrentBar in the string for DrawArrowDown (or Up), could I then convert that back to an int and subtract the stored CurrentBar from the current CurrentBar and get an index?

    #2
    Hello smclrr,

    Thank you for your post.

    You could, but you could also just save that current bar to an int variable and not have to cast the string back to an int. I'd probably go that route for clarity, as it might not be clear why you're using the tag for a drawing object to get a bar index later.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      If I started saving them to a variable, I would have to create a variable to store it in, yes? Or can a script create a variable? I do not really know what I am doing.

      I just saved the currentbar to each arrow that is draw byt the script and saw an opportunity to maybe use that. Does that require a lot to convert the string to an int?

      Comment


        #4
        Hello smcllr,

        To store a drawing object would require creating a variable. If you have a lot of objects you could make a List to collect drawing objects.

        You could use the arrows existing Anchor property to find the bars ago or time it was placed on so you don't need to worry about converting the Tag to an index.

        A simple example of finding the objects Time or BarsAgo looks like the following:

        Code:
        ArrowDown myArrow = Draw.ArrowDown(this, "tag1", true, 0, High[0] + TickSize, Brushes.Red);
        Print(myArrow.Anchor.Time);
        Print(myArrow.Anchor.BarsAgo);
        If you had a lot of objects you could use a C# list to hold all of the items and later loop over them. There is information on using lists in the following link:

        Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.


        A very simple example of a list in NinjaScript would be the following:

        Code:
        List<ArrowDown> myArrows = new List<ArrowDown>();
        
        protected override void OnBarUpdate()
        {
            ArrowDown myArrow = Draw.ArrowDown(this, "tag1", true, 0, High[0] + TickSize, Brushes.Red);
            myArrows.Add(myArrow);
        }
        The myArrows list could be used later to loop over and find certain objects or do an action for each object like checking its bars ago.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        90 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        137 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        120 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        71 views
        0 likes
        Last Post PaulMohn  
        Working...
        X