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

Plot colors

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

    Plot colors

    Trying to set the RSI to plot Black below 49, Green above 51, and DarkGray between 49 and 51. I have the code below. It plots the Black below 49 and Green above 51 but its not plotting the Darkgrey in between 49-51. Its just blank or white. Its not picking up the 3rd plot command. Any idea?...

    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Bar, "Bear"));
    Add(
    new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Bar, "Bull"));
    Add(
    new Plot(Color.FromKnownColor(KnownColor.DarkGray), PlotStyle.Bar, "Neutral"));
    CalculateOnBarClose =
    true;
    Overlay =
    false;

    // multi colored lines based on indicator values
    Plots[0].Max = 49;
    Plots[
    1].Min = 51;
    Plots[
    2].Min = 49;
    Plots[
    2].Max = 51;
    }


    protectedoverridevoid OnBarUpdate()
    {
    if (CurrentBar < Period) return;


    // Calculate RSI value
    double value = RSI(period,3) [0];

    // Set the plot value
    Bear.Set(value);
    Bull.Set(value);
    Neutral.Set(value);
     

    }

    #2
    Hi zachj,

    This technique is not recommended, as it is not efficient and can be more complicated than needed.

    For multicolored plots, please see this reference sample for version 7:


    With this technique, you use only one plot and just conditionally assign PlotColors[][] property.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      That looks even more complicated, im not following it and getting all sorts of errors.

      Comment


        #4
        In fact i just plugged in the exact code provided in your link for SampleMultiColoredPlot_NT7.zip and it comes up with multiple errors. Just spent that last 2hours trying to convert my code to mimic this one and the code im trying to replicate doesn't even work! lol

        Comment


          #5
          You'll find there's more than one way to do thing in programming. You're welcome to use that older approach, but it may not work like you expect, is less efficient, it can get complicated with multiple plots and thresholds, and you would have to integrate the .Reset command to prevent overlapping lines.

          That looks even more complicated, im not following it and getting all sorts of errors.
          If you're looking for help on something, always share your progress and any messages you don't understand. Comments like this don't provide us much to go on in order to help you.

          If you're just stuck completely, hopefully the attached file can provide some direction for you. If you are looking for further customization, please consider a NinjaScript consultant,who are 3rd party partners that can create indicators for you as a fee-based service.


          To import:

          1. From the Control Center window select the menu File > Utilities > Import NinjaScript to open the Import NinjaScript dialog window
          2. Select the file you want to import
          3. Press the "Open" button
          Attached Files
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Well unfortunately as I stated above the code you provided doesn't work, go try to compile the codes of the link you provided. Stricken with errors.

            Comment


              #7
              And also the code I originally submitted was the recommended code from ninja trader tutorial for mutiple plot colors that was just emailed to me from support yesterday. Here's the link...

              Comment


                #8
                Hello,

                What version of NinjaTrader are you on, this code only works with NinjaTrader 7, this is located in the Control Center under Help->About and is to the right of the NinjaTrader logo.

                The sample code does work on my side. I suspect you have another file that could be causing issues.

                When you compile can you take a screenshot of the compile errors.

                To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

                Comment


                  #9
                  I have the latest version of NT. I will look at that Help link. Either way I started from scratch and created a fresh new indicator.. and my original code worked. I changed the order to Bull, Neutral, Bear. Not sure if that made a difference, I doubt it. Ive attached the code and an image of the indicator I was going for, I put the regular RSI indicator above the cutom indicator.
                  Now I just have to figure out how to add an EMA of the RSI to this code, and have it colored Green when both the RSI and the EMA are above 50, and Black when both are below.

                  Attached Files

                  Comment


                    #10
                    oops i just attached the relevant part of the code so that .cs file is not a working file. Meant to attach a txt file.

                    Comment


                      #11
                      RSI Plot

                      Hi

                      I'd also like to change the plot color of price bars when the RSI is above/below a certain Value.

                      I've tried all the code on this thread and can't get it past the compiler the @RSI code you posted is the closest but i get the following compiler errors.

                      CS018 "Ninjatrader indicator" Namespace violation
                      CS0102 already contains a definition for Cache RSI
                      CS0246 Type or namespace data series could not be found.

                      What I'd like to do is be able to plot the price bars, in relation to the RSI value, a particular color when the rsi is above or below a specified value. In an ideal world I'd also like to change the color of the RSI plot when above or below a specified value.

                      Any help you can give with this would be greatly appreciated. I'm using Ninjatrader 8

                      Comment


                        #12
                        Hello Ninjeeta,

                        Thank you for your inquiry and welcome to the NinjaTrader Support Forum!

                        You will want to utilize the BarBrushes collection to paint your price bars a certain color. More information about BarBrushes can be found here: http://ninjatrader.com/support/helpG...barbrushes.htm

                        For example, if you would like to paint the current bar blue if the RSI is above 20 (ensure to replace int period and int smooth with the values you desire):
                        Code:
                        if (RSI(int period, int smooth)[0] > 20)
                             BarBrushes[0] = Brushes.Blue;
                        I would also suggest taking a look at the Code Breaking Changes section of the NinjaTrader 8 help guide for a high level overview of the NinjaScript changes you can expect between NinjaTrader 7 and NinjaTrader 8: http://ninjatrader.com/support/helpG...ng_changes.htm

                        Please, let us know if we may be of further assistance.
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank You

                          Much appreciated

                          Comment


                            #14
                            RSI Lines

                            How can I add more Lines (20, 50, 80) to RSI Indicators or there is RSI Indicator with 5 lines?

                            Comment


                              #15
                              Hello _Gabor_,

                              Thank you for writing in.

                              You can add more lines to the RSI indicator by utilizing the AddLine() method call. Please note that you will not be able to modify the indicator directly; you will need to save a new copy of the indicator and modify that copy.

                              To do this, just open the RSI indicator in the NinjaScript Editor. Once it's open, right click the displayed code and select Save As.

                              For more information about AddLine(), please take a look at the NinjaTrader 8 help guide at this link: http://ninjatrader.com/support/helpG...s/?addline.htm

                              Please, let us know if we may be of further assistance.
                              Zachary G.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              45 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              21 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              181 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X