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

Horizontal Line overlay

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

    Horizontal Line overlay

    Many indicators can be overlaid so that one shows the effects of another. Example: EMA Slope Color set to "1" can be overlaid with, say, CCI(14) so that the lines going up are one color and the lines going down are another color.
    I'd like to be able to do this with a horizontal line, so the line color changes, as with the CCI(14) example above. I tried using the Constant Line indicator with overlays, but it won't change the color of a horizontal line. Any ideas? I was able to rewrite the Constant Line indicator so it only had one line (not 4), but this still didn't work.
    Thanks!
    RR

    #2
    Hello ranradd,

    Thank you for your post.

    So you are just trying to change a manually drawn Horizontal Line when the CCI reaches certain points?

    Can you provide a screenshot of what this looks like on your chart?

    To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

    Click here for instructions: http://windows.microsoft.com/en-us/w...#1TC=windows-8

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

    Click here for detailed instruction: https://www.java.com/en/download/faq/screenshot.xml

    I look forward to your response.

    Comment


      #3
      Horizontal Line overlay

      Hi Patrick, thanks for the response. To answer your first question, no, not trying to change the horizontal line when an indicator, in this case the CCI, reaches a value. I'm just trying to change the color of the horizontal line based on if the CCI (or other indicator) is rising or falling. The image I've attached shows a standard CCI(14). The other line is an EMA line that changes color, set to 1, and then overlaid with a CCI(20). The only reason for the different values is so they are not on top of each other. So, I'd like to be able to overlay an indicator, such as CCI (or other oscillator) on a horizontal line.
      Attached Files

      Comment


        #4
        Hello ranradd,

        Thanks for the reply.

        You can change the color of your plot on a bar-by-bar basis by using PlotBrushes.



        There is an example of how to use PlotBrushes in the example on that page.

        If you added these lines via AddLine, then you would need to replace those lines with plots that plot at constant values, then change the PlotBrushes of those plots.

        Please let me know if I can assist further.
        Last edited by NinjaTrader_ChrisL; 08-10-2018, 02:12 PM.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your info and instructions on PlotBrushes. Unfortunately, I really don't know how to program the NT code, so it would all be guess work. Still, you have not addressed my initial query about the overlay ability in NT, where one indicator can be overlaid on another. What I would like to do is overlay an indicator onto a horizontal line, so that the horizontal line changes color based on the indicator (moving average or oscillator) going up or down. I'm not sure why this doesn't work since it does work when I overlay an oscillator onto a moving average that changes color (up or down) by setting the MA to 1, then overlaying the indicator onto the MA. Perhaps you aren't familiar with how this works since it isn't using the NT programming, but just a trick in indicator application (an extremely useful one for us non-programmers who just trade).
          Last edited by ranradd; 08-12-2018, 10:11 AM.

          Comment


            #6
            Hello ranradd.

            Thanks for the reply.

            I am unaware of a default indicator that changes colors in the way you described. You will need to use PlotColors to change the color of plots:

            https://ninjatrader.com/support/help...plotcolors.htm - PlotColors

            To change the color of a horizontal line, you will need to add a plot with the Add method, then set constant values to the plot to make your own horizontal line.

            https://ninjatrader.com/support/helpGuides/nt7/?add.htm - Add

            This tutorial is a good starting point for working with plots:


            Please let me know if I can assist further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks for the info. Are you familiar with the overlay ability of NT indicators in general? Any indicator can be overlaid onto another, though obviously this has limited use.
              As I mentioned, I am not a programmer, though I do know how to set up charts and use the overlay ability pretty well. So my main interest is why a horizontal line can't be overlaid by another indicator, and show the result. Probably in the code of the horizontal line, as in the indicator Constant Lines, but I don't know how to recognize that in the code.
              Last edited by ranradd; 08-14-2018, 08:52 AM.

              Comment


                #8
                Hello ranradd,

                Thank you for the reply.

                This thread will remain open for other community members that would like to assist you with creating this indicator. You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

                To make this type of script will require that you unify the two indicators that you want to overlay. In this case, it would be the CCI and constant lines. I have attached an example where if the CCI is below the 0 line, the line is red. If the CCI is above the 0 line, the line is Green.

                Please see these instructions on importing the script:


                Make sure you say "No" to replacing the @SMA files.

                Please let me know if I can assist further.
                Attached Files
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chris, Thanks for the reply. really appreciate your assistance regarding this.Thanks for the CCI with a zero line that changes color. I'll look at the code, and see if I can figure out what you did.

                  Anyway, still not sure you understand what I mean about overlays. Here is a step by step to do an overlay without knowing any code or programming, just using the functionality and tools within the NT Indicator panel.
                  1. On any chart, right click and choose Indicators.
                  2. Select SMA by double clicking. (just to keep this simple, but could choose any other MA)
                  3. Set value of SMA to 3.
                  4. Set "Calculate on bar Close" to False.
                  5. This is the key step: On the "Input Series" click on the line to the right which is showing the name of the product, such as NQ-09-18. A small box with 3 dots appears at the end of the line. Clicking on this opens the "Input Series" box.
                  6. The "Input Series" dialog box pops up. Click on the plus symbol next to "Indicators" (very top). All the indicators will show up as a drop down list.
                  7. Select anything. I'll use CCI since we have been talking about it.
                  8. The default value is 14, but it could be changed. (Note: on the "Input Series" in the Parameters section can be clicked on and another Indicator could be chosen to overlay, and this can be done multiple times)
                  9. Click OK at the bottom. This takes you back to the original "Indicators" box.
                  10. Go down to "Visual" and in the "Panel" select New Panel.
                  11. Click OK at the bottom of the Indicators box.
                  12. A 3 period SMA of the 14 period CCI is generated.
                  13. ConstantLines could then be added to this Panel, to show some horizontal lines, or, this could be added to a default CCI panel, which has horizontal lines already. Now you have a MA of the CCI.

                  This is not what I use. Just used this example to show the steps of how to create this.

                  I have an EMA called EMA_Slope_Color I got from the forum, that changes color for up and down.
                  Using the above technique, I add the EMA, set the EMA value to 1, overlay a CCI (14), or anything else, and end up with a CCI that changes color going up or down. Since the EMA is set to 1, it doesn't add anything to the values, just contributing the color changes.

                  This is what is shown in the image I sent earlier, though I changed the CCI to 20 so it didn't block out the CCI(14) line.

                  I understand this is not as elegant as programming the CCI to have up and down colors. But this functionality is built into NT, is easily used, and works.

                  But, for some reason this overlay technique won't work when trying to overlay onto a horizontal line, such as in ConstantLines. Not sure why. I even tried editing the code of ConstantLines so there was only one horizontal line generated (I'm not a programmer, but could figure that much out). Still didn't work. There must be something in the code of the Horizontal line function that prevents this sort of overlay that I can't figure out.

                  Perhaps I will have to hire someone. Anyway, hope you finally understand what I'm doing.
                  Last edited by ranradd; 08-15-2018, 10:02 AM.

                  Comment


                    #10
                    Hello ranradd,

                    Thanks for the follow-up.

                    This will not work for the constant lines indicator because you can not change the color of a horizontal line in sections. Note that I commented out the
                    Code:
                    Add(new Line(Color.DarkGray, 0, "Zero line"));
                    line in the CCI code example and replaced it with a plot that plots 0 at every bar. That allows me to change the color of the horizontal line based on the value of the CCI. The constant lines indicator does not need to be involved if you modify the script. The only caveat is that you would need to do this edit for every indicator you want horizontal lines on.

                    Please let me know if I can assist further.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Chris, thanks so much for your reply. I think I'm getting it.
                      I tried changing the code in ConstantLines as you suggested. Really I'm just cut and paste guessing.

                      {
                      //Add(new Plot(Color.Tan, PlotStyle.Line, "Line1"));
                      Add(new Plot(Color.LimeGreen, "ZeroLine"));

                      ChartOnly = true;
                      AutoScale = false;
                      CalculateOnBarClose = true;
                      DisplayInDataBox = false;
                      Overlay = true;
                      }

                      That worked and I got a Limegreen line. The code in the "protected override" section seems to be what is telling the line to change color or not. I can see you telling it to be red or limegreen. But your code is using an SMA. How are you calling up the CCI? I'm confused.

                      Really, my hope is to have four horizontal lines on one panel, that show the rising and falling of certain indicators, CCI, %R, EMA, and SMI to be used on a higher time frame than the lower time frame I trade from.

                      Comment


                        #12
                        Hello ranradd,

                        thanks for the follow-up.

                        I recommend going through this tutorial that changes colors based on threshold values.



                        Doing all of the tutorials will be a good exercise overall. If you get stuck on the C#, I recommend this publicly available site:

                        Browse examples for many languages, with explanations and code side by side for easy understanding.


                        Please let me know if I can assist further.
                        Chris L.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by adeelshahzad, Today, 03:54 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by stafe, 04-15-2024, 08:34 PM
                        7 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by merzo, 06-25-2023, 02:19 AM
                        10 responses
                        823 views
                        1 like
                        Last Post NinjaTrader_ChristopherJ  
                        Started by frankthearm, Today, 09:08 AM
                        5 responses
                        21 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        43 views
                        0 likes
                        Last Post jeronymite  
                        Working...
                        X