Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	294
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
    Brandon H.NinjaTrader Customer Service

    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:	246
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.
        Brandon H.NinjaTrader Customer Service

        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
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by geddyisodin, Yesterday, 05:20 AM
            8 responses
            51 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            10 responses
            36 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by DayTradingDEMON, Today, 09:28 AM
            4 responses
            24 views
            0 likes
            Last Post DayTradingDEMON  
            Started by George21, Today, 10:07 AM
            1 response
            17 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by Stanfillirenfro, Today, 07:23 AM
            9 responses
            25 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X