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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        81 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        41 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        66 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X