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 NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X