Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trend Line

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

    Trend Line

    I have a strategy that I have created with the wizard. I do not want to unlock it. I have a condition that determines an Uptrend is true. My question is how can I tell the Strategy, using the wizard, to draw a line from the first low that the uptrend conditon is true to the last low that the conditon is true? (UpTrendLine)

    #2
    Hello Kenb2004,

    Unfortunately I can't think of a way to do this with the wizard. You would need to capture CurrentBar values at the time of the condition, and the wizard doesn't offer this. You will most likely need to unlock the code and custom program this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      That's very disappointing, because I've tried using "diamonds" to track the Trend when condition is true and it makes a drawing object for every bar which really seems to bog down NinjaTrader, especially when using the Strategy Analyzer.

      Comment


        #4
        If the drawing objects are bogging your system down, maybe consider changing bar color or using the other visual cues.

        See the link below for reducing NinjaTrader's resource requirements, which may help your system run more efficiently.
        Click here to view the NinjaTrader performance tips
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          How would change color have any affect on performance? I am trying to use other visual cues, that why I want to draw one line instead of 30 or 40 diamonds. If I unlocked the code how would you program the TrendLine from low to low as long as the conditon was true?

          Comment


            #6
            Drawing creates a separate object to track for each bar. BarColor changes the property of existing bars. It doesn't add new objects.

            There may be other ways to implement through code. Here's just one:

            You could setup two sequences and use a bool flags to create the sequence you're looking for.

            Example Snippet:

            Code:
             
            #region Variables
            private bool firstBar;
            private int conditionBar;
            private int barsAgoValue;
            #endregion
             
            if (Close[0] > Open[0] && firstBar)
            {
            conditionBar = CurrentBar;
            firstBar = false;
            }
             
            else if (!firstBar)
            {
            barsAgoValue = CurrentBar - conditionBar;
            firstBar = true;
            DrawLine("line" + CurrentBar, barsAgoValue, Low[barsAgoValue], 0, Low[0], Color.Red);
            }

            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Could you please define your variables in this example?

              Comment


                #8
                Thery're defined in the snippet - in the variables region.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  private bool firstBar;
                  private int conditionBar;
                  private int barsAgoValue;

                  firstBar and conditionBar, what is the difference?
                  barsAgoValue, what is the purpose?

                  Comment


                    #10
                    firstBar is the bool flag. It's used to create the sequence - first check when the condition is true, next check when it's not.

                    conditionBar captures the CurrentBar value for the bar that the condition occurred.

                    barsAgo tells us how many bars back the first condition occurs.
                    Ryan M.NinjaTrader Customer Service

                    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