Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    -EC_Chris-
    NinjaTrader Ecosystem Vendor - Emergent Cybernetics

    #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.
    JesseNinjaTrader Customer Service

    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"
      -EC_Chris-
      NinjaTrader Ecosystem Vendor - Emergent Cybernetics

      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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Gerik, Today, 09:40 AM
        2 responses
        6 views
        0 likes
        Last Post Gerik
        by Gerik
         
        Started by RookieTrader, Today, 09:37 AM
        2 responses
        10 views
        0 likes
        Last Post RookieTrader  
        Started by alifarahani, Today, 09:40 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by KennyK, 05-29-2017, 02:02 AM
        3 responses
        1,285 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by AttiM, 02-14-2024, 05:20 PM
        11 responses
        186 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X