Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Arrow at Current Bar - Period Lookback

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

    Draw Arrow at Current Bar - Period Lookback

    I am probably overthinking this, but the code I am using is not working.

    I need arrows to plot on the all the bars that occurred before a period offset from the current bar.

    For example, in my screenshot I am using the built-in Regression Channel with a period of 5. What I need is for every bar prior to the regression channel plotting to show an arrow.

    I have been messing with this code to plot it, but I think I am backwards here and can't quite get my head around it.

    period = 5;

    Code:
    			if((CurrentBars[0]-period)+1 > period)
    				
    			{
    				Draw.ArrowUp(this, "arrow" + CurrentBar, true, 0, High[0] + 2 * TickSize, Brushes.Cyan);
    			}
    Attached Files

    #2
    Hello EC_Chris,

    Thank you for the post.

    I wanted to clarify, you want to have an arrow on Every bar except where the regression channel is, or you wanted to have a number of arrows before that point, for example, 5 arrows leading to the channel?

    If this should be on every bar, likely a bool is the easiest way to do that. You could always draw the arrows unless the condition to draw your channel becomes true, and then set the bool to stop the arrows from drawing.

    If you wanted a number of bars before the channel, you may instead need to use a for loop to make arrows for the past bars where they should be present.

    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse
      What I am looking for is this:

      "you want to have an arrow on Every bar except where the regression channel is"

      Comment


        #4
        Hello EC_Chris,

        Thank you for the reply.

        Yes in this case, I believe a bool could work but this would be something you will have to review in contrast to your logic.

        A simple example would be:

        Code:
        if(SomeCondition == true)
        {
            // draw channel logic
            canDrawArrow = false;
        } 
        else if(SomeOtherCondition == true)
        {
            canDrawArrow = true; // reset so the arrow can draw again. 
            //Perhaps if you know how long the channel will be, you can use the period to store the value of a bar in the future from now in which this should reset. 
        }
        
        if(canDrawArrow)
        {
            Draw.ArrowUp(this, "arrow" + CurrentBar, true, 0, High[0] + 2 * TickSize, Brushes.Cyan);
        }

        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 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
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X