Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about accessing the PlotBrushes series of an indicator from a strategy

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

    Question about accessing the PlotBrushes series of an indicator from a strategy

    I am trying to read the plot color of the last bar from a strategy but the color returned is always empty.

    Can you help ?

    Here is what i am doing:

    I have this class wide variable defined which holds a collection of indicators on the chart:
    private List<NinjaTrader.Gui.NinjaScript.IndicatorRenderBa se> indicatorCollection;


    In a method i have this code
    ============================

    // define the variable which will hold a ref. to an underlying indicator on the chart
    NinjaTrader.Gui.NinjaScript.IndicatorRenderBase _indicator;

    // get an indicator from the collection
    _indicator = indicatorCollection[i];

    // loop through all the plots created by this indicator
    int _plotsCount = _indicator.Values.Length;
    for (int _plotIndex = 0; _plotIndex < _plotsCount ; _plotIndex++)
    {
    int _lastBarPainted = ChartBars.ToIndex - (_indicator.Calculate == Calculate.OnBarClose ? 1:0);
    Plot _plot = _indicator.Plots[_plotIndex];
    BrushSeries _plotBrushes = _indicator.PlotBrushes[_plotIndex];
    Brush _plotColor = _plotBrushes[_lastBarPainted];
    }

    Print(_plot.Name + " " + _plotColor); // <- i always get an empty content for the _plotColor variable


    There is no script error and the indicator name is displayed in the output window but the _plotColor is empty and i can't understand what's wrong in my code.​

    #2
    Hi, thanks for posting. The ChartControl object has a collection of indicators that you can use to get the PlotColor:

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi, thanks for posting. The ChartControl object has a collection of indicators that you can use to get the PlotColor:
      https://ninjatrader.com/support/help...indicators.htm
      My script is already using this ChartControl object to get the collection of indicators on a chart. However, if i try these commands:
      BrushSeries _plotBrushes = _indicator.PlotBrushes[_plotIndex];
      Brush _plotColor = _plotBrushes[_lastBarPainted];

      _plotColor is empty. Do you have any idea why?

      Comment


        #4
        I finally was able by forgetting about the PlotBrushes[] BrushSeries.

        I used this instead:
        Plot _plot = _indicator.Plots[_plotIndex];
        Brush _plotColor = _plot.Brush;

        Don't know why the other approach did not work though.

        Comment


          #5
          Hi, Im also noticing the PlotBrushes[0] is an empty array in this context. I will check to see if this is expected or not.

          Comment


            #6
            Hi, It looks like this output is expected. The same thing will happen if you host an indicator in a parent script, the parent script will not have access to the PlotBrushes[][] array of the hosted indicator. I will submit a feature request to ask our development team to make PlotBrushes available to other scripts that access an indicator's PlotBrushes array.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            46 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            66 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X