Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

3 Linecolors

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

    3 Linecolors

    Hi,

    I've an indicator that I would like to plot 3 different line colors. I'm having issues under PlotBruses[0][0]..... for the NeutralBrush. How would the correct way to be to include all 3 brushes?

    Code:
    lineColor[0] = <code>? 1 : <code>? 0 : <code>? -1 : lineColor[1];
    
    PlotBrushes[0][0] = lineColor[0] == 1 ? BullBrush : BearBrush;
    
    PlotBrushes[0][0] = lineColor[0] == 0 : NeutralBrush;
    ​
    Thanks

    #2
    Hello AgriTrdr,

    What are the rules you want?

    Are you wanting 1 to be BullBrush, -1 to be BearBrush, and 0 to be NeutralBrush?

    You could nest the ternarys.

    PlotBrushes[0][0] = lineColor[0] == 1 ? BullBrush : ((lineColor[0] == -1) ? BearBrush: NeutralBrush);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes that's what I'm trying to accomplish, but the lines show up as BullBrush even though if it should be a Bear/Neutral Brush.

      Comment


        #4
        Hello AgriTrdr,

        Please provide output from prints.


        What is the lineColor[0] value?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          lineColor[0] would always be 1.

          I tried changing the logic before PlotBrushes to:

          Code:
          if (code)
          
          {
          
          lineColor[0] = 1;
          
          }
          
          else if (code)
          
          {
          
          lineColor[0] = 0;
          
          }
          
          else if (code)
          
          {
          
          lineColor[0] = -1;
          
          }
          
          else
          
          {
          
          lineColor[0] = lineColor[1];
          
          }
          ​
          instead of previously:

          Code:
          lineColor[0] = <code>? 1 : <code>? 0 : <code>? -1 : lineColor[1];
          After the change the lineColor[0] is still 1.

          Comment


            #6
            Hello AgriTrdr,

            If lineColor[0] is one after this assignment, this means that your first <code> is resulting in a value of true.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I rewrote the code below. Would PlotBrushes[0][0] be what it is below or do I need to change it? All 3 colors are plotting, but the issue is that when downTrend occurs the first bar is correct, but then it goes to yellow. On the upTrend, it stays blue.


              Code:
              if (Bars.IsFirstBarOfSession)
              
              {
              
              Trend[0] = Open[0];
              
              upTrend = false;
              
              downTrend = false;
              
              neutralTrend = true;
              
              }
              
              
              else if (code)
              
              {
              
              Trend[0] = Low[1];
              
              upTrend = true;
              
              downTrend = false;
              
              neutralTrend = false;
              
              }
              
              
              else if (code)
              
              {
              
              Trend[0] = High[1];
              
              upTrend = false;
              
              downTrend = true;
              
              neutralTrend = false;
              
              }
              
              
              else if (((upTrend == true) && (Open[0] <= Trend[0] && Close[0] <= Trend[0])) || ((downTrend == true) && (Open[0] >= Trend[0] && Close[0] >= Trend[0])))
              
              {
              
              Trend[0] = Trend[1];
              
              upTrend = false;
              
              downTrend = false;
              
              neutralTrend = true;
              
              }
              
              
              else
              
              {
              
              Trend[0] = Trend[1];
              
              }
              
              
              if (upTrend == true && downTrend == false && neutralTrend == false)
              
              {
              
              lineColor[0] = 1;
              
              }
              
              else if (upTrend == false && downTrend == true && neutralTrend == false)
              
              {
              
              lineColor[0] = -1;
              
              }
              
              else if (upTrend == false && downTrend == false && neutralTrend == true)
              
              {
              
              lineColor[0] = 0;
              
              }
              
              
              PlotBrushes[0][0] = lineColor[0] == 1 ? BullBrush : ((lineColor[0] == -1) ? BearBrush: NeutralBrush);
              
              ​

              Comment


                #8
                Hello AgriTrdr,

                What is the value of lineColor?

                Add debugging prints to know which if conditions are evaluating as true.

                Provide output.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Please see below Output. 1 works, but for -1, it works on the 1st bar, but it goes to 0 after that.

                  11/15/2024 2:07:00 PM|MES 12-24|LineColor|-1

                  11/15/2024 2:08:00 PM|MES 12-24|LineColor|-1

                  11/15/2024 2:09:00 PM|MES 12-24|LineColor|0

                  11/15/2024 2:10:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:11:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:12:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:13:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:14:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:15:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:16:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:17:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:18:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:19:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:20:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:21:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:22:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:23:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:24:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:25:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:26:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:27:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:28:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:29:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:30:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:31:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:32:00 PM|MES 12-24|LineColor|-1

                  11/15/2024 2:33:00 PM|MES 12-24|LineColor|0

                  11/15/2024 2:34:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:35:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:36:00 PM|MES 12-24|LineColor|1

                  11/15/2024 2:37:00 PM|MES 12-24|LineColor|-1

                  11/15/2024 2:38:00 PM|MES 12-24|LineColor|0

                  11/15/2024 2:39:00 PM|MES 12-24|LineColor|0

                  11/15/2024 2:40:00 PM|MES 12-24|LineColor|0

                  11/15/2024 2:41:00 PM|MES 12-24|LineColor|0

                  Comment


                    #10
                    Hello AgriTrdr,

                    Add debugging prints to know which if conditions are evaluating as true.

                    Provide output.​
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    637 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    366 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    107 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    569 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    571 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X