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

Chart background color based on indicator output

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

    Chart background color based on indicator output

    I was wondering if there was a way to edit an indicator to change the chart background color, and to actually do it globally so all my charts background colors change, based on the current value of the indicator. Although it sounds simple, I want to have a green background when RSI > 50 and a red background when RSI < 50.

    Searching the topics here hasn't led to anything similar. I'm not a programmer, but I can bump my way around the strategy wizard, so I was curious if there was a similar wizard for indicators.

    #2
    Hello qphage,

    Thank you for your reply.

    To clarify, are you wanting the chart background to change based on the value of the RSI of one of the charts on all the other charts, or would you want it to use the RSI value of whatever the primary series bars are? For example, an RSI on a 5 minute chart will have different values than an RSI on a 60 minute chart. For example, if you place the indicator on a 1 minute chart, would you want the backgrounds of all the charts to change based on the 1 minute chart's RSI values?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,
      I'm basically only using 2 charts, both 5 minute, but the RSI on the 1st chart, or the one I want to trigger the changes, won't match the RSI on the second chart because the first chart will be a line-break chart, and the second a regular candle chart. That's why I want global changes, so that when RSI 1st chart > 50, both backgrounds change to green..( < 50 both red).
      To answer your question as well, if not more complex - yes, I would like the 5 minute line break trigger chart (1st) to customize the second chart whatever the interval is set to (on the 2nd chart) 1,5,15 min etc.
      Hope that is clearer....
      Gary.

      Comment


        #4
        Hello qphage,

        Thank you for your reply.

        While there is indeed an Indicator Wizard in the platform that comes up in the NinjaScript Editor when you right click on the Indicator folder on the right and select New Indicator, this isn't a full fledged indicator builder like the Strategy Builder. It can only set up basic things like added series, plots, and user inputs. Any other code you'd have to manually create.

        That being said, I've created a simple example indicator that calls the RSI on a basic 5 minute series (the RSI period and smooth settings are customizable user inputs, but the RSI will always be calculated on the added 5 minute series and when applied to a chart, will color the background of the chart green if the current 5 minute RSI value is 50 or above and red if it's 50 or below. I've put a number of comments in the code so you can use this as a learning example off which to base your own code.

        For example, if you wanted to use a 5 minute line break series instead of regular 5 minute candles you could swap out the call to AddDataSeries with a call to AddLineBreak:



        You can then apply this to each chart you want to see the current background color change based on that RSI.

        Please let us know if we may be of further assistance to you.
        Attached Files
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          My extreme thanks for this Kate, and sorry for such a long delay with my reply.
          It is doing just as I asked, and I'm having some fun tweaking it for use on other time frames.

          I was wondering, could you direct me to a tutorial that walks through adding code that can adjust the area's opacity?
          OR AND, can add that function to the indicator's dialog box?

          Gary

          Comment


            #6
            Hello qphage,

            Thank you for your reply.

            For that you would need to create and freeze a new solid color brush using FromArgb:

            // set the background brush for every bar to green
            Brush myBrush = new SolidColorBrush(Color.FromArgb(100, 0, 255, 0));
            myBrush.Freeze();

            BackBrushAll = myBrush;

            The first number (100) there is the opacity. Higher is more opaque The other values are standard RGB values - you can use online color pickers to help you get the values you'd want for those.

            You can then create an input if you like to get an opacity value from the user and then use that variable in place of the opacity value.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by tsantospinto, 04-12-2024, 07:04 PM
            4 responses
            62 views
            0 likes
            Last Post aligator  
            Started by michi08, 10-05-2018, 09:31 AM
            3 responses
            740 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by sightcareclickhere, Today, 01:55 PM
            0 responses
            1 view
            0 likes
            Last Post sightcareclickhere  
            Started by Mindset, 05-06-2023, 09:03 PM
            9 responses
            259 views
            0 likes
            Last Post ender_wiggum  
            Started by Mizzouman1, Today, 07:35 AM
            4 responses
            18 views
            0 likes
            Last Post Mizzouman1  
            Working...
            X