Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar color in strategy

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

    Bar color in strategy

    I have a proprietary indicator that colors the price bars, and I was wondering about using it in a strategy (i.e., testing bar color). I'm just starting to explore strategy programming, so as a first pass all I did was add the indicator to a strategy. The result was the bars were not colored on the chart in Strategy Analyzer after a backtest, even though the indicator did show up in the indicator list for that chart.

    My next step was to create a test not based on anything proprietary. I wrote a simple indicator to color rising bars green (meaning higher high and higher low compared to prior bar), falling bars red (lower high and lower low) and all other bars blue. The indicator worked fine on charts. (See first screen shot.) Then I threw together a rudimentary strategy, added my indicator and ran a backtest. And the backtest produced a very strange chart. (See second screen shot. Note that you don't see three colors, and that some candles have wicks but no bodies.)

    I've attached a .zip file containing an export of my indicator and strategy. The backtest was run against ES 3-minute data.

    Is this an NT issue, did I make a mistake in implementation, or is bar coloring not supported in strategies for some reason?

    Click image for larger version

Name:	Regular Chart.jpg
Views:	1
Size:	32.7 KB
ID:	895305 Click image for larger version

Name:	Backtest Chart.jpg
Views:	1
Size:	40.0 KB
ID:	895306 StrategyQuestion.zip

    #2
    Mike, please try coding the color conditions directly into the strategy and see if you are able to plot colors then. It worked on my end, and if you are able to do that but not through an intermediate indicator, then perhaps this is a bug.
    AustinNinjaTrader Customer Service

    Comment


      #3
      When I embedded the code to color the bars into the strategy, the bars colored as expected. (Unfortunately that's not a workaround for the proprietary indicator I mentioned earlier since I can't access that source code.) Think we've got a bug here?

      Note: I've attached the revised strategy with the code to color the bars added and the reference to the indicator removed.

      Click image for larger version

Name:	Backtest2.jpg
Views:	1
Size:	38.1 KB
ID:	858731 ColorTest.zip

      Comment


        #4
        Mike, I just tried setting bar colors from an indicator embedded in a strategy and everything worked fine. Please try setting the bar color directly and not through an intermediate variable.
        Attached Files
        AustinNinjaTrader Customer Service

        Comment


          #5
          Thanks for exploring this, Austin, but unfortunately your finding doesn't really help me. As I indicated originally, I started down this path because I was wondering about testing the bar color set by a proprietary indicator within a strategy, but I couldn't get the bar color to set. I can't access the code in that proprietary indicator so I can't change anything about how the color is set. (I do know the colors are user-configurable, so clearly variables are involved. But again, nothing I can do about it.) I still think you need to address why an indicator that works fine on a chart doesn't work properly within a strategy.

          Comment


            #6
            MikeInMA, I just tested this again with your code and the bars did change color as expected, although I'm not sure why some candles were filled in and others weren't. Are you sure you re-compiled your script after you made changes? I'll have someone take a look tomorrow.
            Attached Files
            AustinNinjaTrader Customer Service

            Comment


              #7
              If I'm not mistaken, your attachment is a chart to which the strategy was applied. I ran a backtest on my strategy through Strategy Analyzer, and in earlier posts I showed charts that Strategy Analyzer generated. Bars on those charts were not colored correctly.

              Again, the fundamental issue is that I want to test bar color in Strategy Analyzer, where bar color will (hopefully) be set by a proprietary indicator I can't change but that almost certainly uses variables for colors since the colors are specified as user inputs. I really have to ask you to focus your testing on Strategy Analyzer, or at least be sure Strategy Analyzer is part of the equation.

              Comment


                #8
                Sorry, not sure how I missed that. It definitely looks like something's up for backtest charts. I'll have someone respond tomorrow.
                Attached Files
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Mike, thanks for reporting in - I could reproduce it here on the SA charts - we'll look into matters.

                  Comment


                    #10
                    Sounds good. Hopefully this will make it to the official bug list and get fixed in the next release. I'll stay tuned....

                    Comment


                      #11
                      Mike, thanks for reporting this in, it will be fixed in the next beta round - same would apply to setting CandleOutlineColor.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      633 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      364 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      105 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      567 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      568 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X