Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coloring rule for Volume of quantity of contracts traded

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

    Coloring rule for Volume of quantity of contracts traded

    Hello everyone,

    I am switching to using NinjaTrader and trading in other markets. On another platform I use a rule for coloring the bars and the Volume Histogram. Something like a heatmap.

    Basically it is a weighted average of the last 400 periods (bars of the histogram) and incremented with standard deviation calculations. And that paints the bars in warmer colors indicating an increase in volume.

    I have the Groovy script on which this indicator was made. I tried to transcribe it to C # in NinjaScript, but I was unsuccessful.

    The image below shows the idea.

    I would like help with clarifying how I can resolve this code.

    Thanks!






    Click image for larger version

Name:	Screenshot_7.jpg
Views:	338
Size:	122.0 KB
ID:	1149657




    #2
    Hello ErionAb,

    Thank you for your post.

    To clarify, are you wanting to know how to color the bars (candles) on the chart and how to color a plot, such as a Volume plot?

    CandleOutlineBrush and Barbrush would be used to determine the color of the bars (candles). CandleOutLineBrush determines the border color of a bar. BarBrush determines the color inside the borders of a bar.

    See the attached example demonstrating using CandleOutlineBrush and BarBrush.

    Also, see the examples in the help guide documentation below for more information.
    CandleOutlineBrush - https://ninjatrader.com/support/help...tlinebrush.htm
    BarBrush - https://ninjatrader.com/support/help...8/barbrush.htm

    Plots or PlotBrushes would be used to determine the color of a plot. Plots would be used to determine the color property of an entire plot. PlotBrushes would be used to determine the color property of specific segments of a plot.

    See the help guide documentation below for more information.
    Plots - https://ninjatrader.com/support/help.../nt8/plots.htm
    PlotBrushes - https://ninjatrader.com/support/help...lotbrushes.htm

    Also, see this help guide for information about working with brushes - https://ninjatrader.com/support/help...th_brushes.htm

    Let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello ErionAb,

      Thank you for your post.

      To clarify, are you wanting to know how to color the bars (candles) on the chart and how to color a plot, such as a Volume plot?

      CandleOutlineBrush and Barbrush would be used to determine the color of the bars (candles). CandleOutLineBrush determines the border color of a bar. BarBrush determines the color inside the borders of a bar.

      See the attached example demonstrating using CandleOutlineBrush and BarBrush.

      Also, see the examples in the help guide documentation below for more information.
      CandleOutlineBrush - https://ninjatrader.com/support/help...tlinebrush.htm
      BarBrush - https://ninjatrader.com/support/help...8/barbrush.htm

      Plots or PlotBrushes would be used to determine the color of a plot. Plots would be used to determine the color property of an entire plot. PlotBrushes would be used to determine the color property of specific segments of a plot.

      See the help guide documentation below for more information.
      Plots - https://ninjatrader.com/support/help.../nt8/plots.htm
      PlotBrushes - https://ninjatrader.com/support/help...lotbrushes.htm

      Also, see this help guide for information about working with brushes - https://ninjatrader.com/support/help...th_brushes.htm

      Let us know if we may assist further.


      Thanks BrandonH,

      It has helped a lot. Just one more question how can I do the SMA calculation for the volume, to later calculate the standard deviation.

      As shown in the image below, the coloring of the volume bars establishes the parameters for the price bars.

      Click image for larger version

Name:	Screenshot_8.jpg
Views:	294
Size:	129.1 KB
ID:	1149683

      Comment


        #4
        Hello ErionAb,

        Thank you for your note.

        You could determine what color segments of a plot are based on certain conditions by using PlotBrushes. First, you could call AddPlot() to add a plot to your script and assign the plot a value. Then, you would need to set up your condition(s) followed by calling PlotBrushes to change the color of the plot. Then, any time that condition becomes true, the plot color for that bar would change to the specified color.

        You could reference an SMA value in your script using SMA() and then calculate the logic for your standard deviation levels and assign them to variables. Those variables would then be used to create your conditions for when you want to set PlotBrushes to change the color of a plot segment.

        SMA - https://ninjatrader.com/support/help...simple_sma.htm
        AddPlot - https://ninjatrader.com/support/help...t8/addplot.htm
        PlotBrushes - https://ninjatrader.com/support/help...lotbrushes.htm

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello ErionAb,

          Thank you for your note.

          You could determine what color segments of a plot are based on certain conditions by using PlotBrushes. First, you could call AddPlot() to add a plot to your script and assign the plot a value. Then, you would need to set up your condition(s) followed by calling PlotBrushes to change the color of the plot. Then, any time that condition becomes true, the plot color for that bar would change to the specified color.

          You could reference an SMA value in your script using SMA() and then calculate the logic for your standard deviation levels and assign them to variables. Those variables would then be used to create your conditions for when you want to set PlotBrushes to change the color of a plot segment.

          SMA - https://ninjatrader.com/support/help...simple_sma.htm
          AddPlot - https://ninjatrader.com/support/help...t8/addplot.htm
          PlotBrushes - https://ninjatrader.com/support/help...lotbrushes.htm

          Let us know if we may assist further.


          Thanks Brandon,

          The NT8 really is extremely powerful. I have already created my indicator, but it is only painting the candles.

          Is it possible to paint the bars of the VOL indicator?

          Comment


            #6
            Hello ErionAb,

            Thank you for your note.

            You could determine the color of a plot, such as the VOL plot, by using Plots or PlotBrushes.

            See the attached example script which demonstrates using PlotBrushes to determine the color for segments of the VOL indicator when a certain condition returns true.

            In State.Configure we initially set the VOL plot to dodger blue. Then we create a condition in OnBarUpdate() that checks if the current Close is greater than the current Open. If the condition returns true, that plot segment for the VOL indicator is painted a goldenrod color using PlotBrushes.

            Let us know if we may assist further.
            Attached Files
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

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