I am using a CCI histogram indicator that has green bars above zero and red bars below zero. I would like to know how I can modify it so that the histogram bars will paint a different color when it goes beyond or below +/-100 (eg. the portion between 0 to +100 will be green, while the portion extending beyond +100 will be in another color, so the bar will have 2 color segments if it's a very big bar)
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!
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
NinjaTrader
CCI Histogram
Collapse
X
-
CCI Histogram
Hello,
I am using a CCI histogram indicator that has green bars above zero and red bars below zero. I would like to know how I can modify it so that the histogram bars will paint a different color when it goes beyond or below +/-100 (eg. the portion between 0 to +100 will be green, while the portion extending beyond +100 will be in another color, so the bar will have 2 color segments if it's a very big bar)Tags: None
-
Hello deraly,
Thanks for your post and welcome to the forums!
A histogram bar could only be one color so to accomplish your goals you would have to add another plot that is also a histogram bar type. Basically, the added plot would be behind the original giving the appearance of two colors on one bar. The first (original) plot would have to, through logic code changes, be limited to +/-100 in the code while the added plot would be the different color when it exceeds +/-100.
To make the modifications you would need access to the source code of the indicator and need to work within the Ninjascript (or other) editor to effect the changes.
Here is a link to the helpguide for adding a plot: http://ninjatrader.com/support/helpGuides/nt7/?add.htmPaul H.NinjaTrader Customer Service
-
Hi Paul,
Thank you for your response. I am not sure where to add the plot, below is the part of the script, can you please help me add the plot in? I am completely helpless. Eg. if I want the bar to be yellow if it exceeds +100 and Pink if it goes beyond -100
Add(new Plot(new Pen(Color.DodgerBlue, 3), PlotStyle.Line, "CCImiddle")); // Between margins.
Add(new Plot(new Pen(Color.Orange, 3), PlotStyle.Line, "CCIoverbought"));// Upper = Overbought (>+50)
Add(new Plot(new Pen(Color.Pink, 3), PlotStyle.Line, "CCIoversold")); // Lower = Oversold (<-50)
Add(new Plot(new Pen(Color.Green, 3), PlotStyle.Bar, "CCIbarHi")); // Histogram above zero.
Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Bar, "CCIbarLo")); // Histogram below zero.
Add(new Line(Color.DarkGray, 200, "Level2"));
Add(new Line(Color.DarkGray, 100, "Level1"));
Add(new Line(Color.DarkGray, 0, "ZeroLine"));
Add(new Line(Color.DarkGray, -100, "LevelM1"));
Add(new Line(Color.DarkGray, -200, "LevelM2"));
Period = 14;
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = true;
// Set the threshold values for each plot
Plots[0].Min = -100; // Not oversold or overbought.
Plots[0].Max = 100;
Plots[1].Min = 100; // Overbought is above this.
Plots[2].Max = -100; // Oversold is below this.
Plots[3].Min = 0; // Overbought is above this.
Plots[4].Max = 0; // Oversold is below this.
Comment
-
Hello deraly,
Thanks for your reply.
Just to be clear, In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.
In a nutshell here is what you would need to do:
Modifying the indicator to accomplish your goals will take some effort as you will need to create the logic to create the effect you are looking for and this will not be a simple add a line here or there.
First, make sure you are working on a copy of the original code. If you haven't already, open the original indicator file and right mouse click in the code and select "save as" and provide a new indicator name.
In the new indicator you would add the two new plots just below the line:
Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Bar, "CCIbarLo")); // Histogram below zero.
(You can copy the two plots and paste them in) Set the two new plots to the colors you want for the down side and for the upside. You will need to make sure you use a unique name for each plot.
Next you would need to create two outputs in the #region Properties that would be similar to what the plots called CCIbarLo and CCIbarHi look like in that area and note the incrementing order of Values, the two you add will need to be 5 & 6 from what I can see.
Next in the OnbarUpdate() method you would need to find where the plots CCIbarLo and CCIbarHi are set, something line CCIbarLo.Set(...) and create a duplicate using the new plot names you created making sure you associate the correct values for up and down.
Finally, where the existing plots CCIbarLo and CCIbarHi are set you will need to add conditions to skip setting them if the value are >+100 or <-100.
If you are not comfortable with coding you might ask someone who is to assist you or alternatively, we can refer you to 3rd party coders that can create your indicator for you.Paul H.NinjaTrader Customer Service
Comment
-
Hello Paul,
Thanks so much for your help, I followed your instructions. I was able to do the first two steps, but I don't know where I should be putting in these 2 steps--
"Next in the OnbarUpdate() method you would need to find where the plots CCIbarLo and CCIbarHi are set, something line CCIbarLo.Set(...) and create a duplicate using the new plot names you created making sure you associate the correct values for up and down.
Finally, where the existing plots CCIbarLo and CCIbarHi are set you will need to add conditions to skip setting them if the value are >+100 or <-100."
Attached is what I have done so far.Attached Files
Comment
-
Hello deraly,
Thanks for your reply.
What you have entered looks good, well done.
Copy these two lines:
CCIbarHi.Set( plotval );
CCIbarLo.Set( plotval );
and then change the copied lines to:
CCIbarHi1.Set( plotval );
CCIbarLo1.Set( plotval );
Go back to CCIbarHi.Set( plotval ); and change as follows:
if (plotval > 100.0)
CCIbarHi.Set( 100.0 ); //limit plot to 100
Go back to
CCIbarLo.Set( plotval ); and change as follows:
if (plotval < -100.0)
CCIbarLo.Set( -100.0 ); // limit plot to -100
Once you have successfully compiled and applied the indicator, if the lower bars are not visible we may need to change this up a bit. If that happens, post your updated code and a screenshot. Almost there.Paul H.NinjaTrader Customer Service
Comment
-
Hello Paul,
I have followed your instruction and compiled the indicator, it is very close to what I am looking for. There is just one more thing that is not quite right, can you please help me? When the bars are over +/-100, they are all in yellow which is fine as long as it is not all green or red bars, so this part is completed. However, there are some yellow bars that are within the +100 and -100 range, I do not understand why this is so. This is the only part left to be corrected. Can you please help me correct this mistake? Thank you so much for your help.
Comment
-
Hello deraly,
In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.
We do have a large ecosystem available to help you with programming logic questions. You can post on our forum and ask the other 40,000+ forum members.
You can also contact a professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
-
dearly thanks for the indicator.
I wanted a CCI that I can make be red above 100 and red below -100 and silver everywhere else and I was able to switch the bars to lines and redo the colors and it's great for what I want.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by selu72, Today, 02:01 PM
|
1 response
4 views
0 likes
|
Last Post Today, 02:17 PM | ||
Started by WHICKED, Today, 02:02 PM
|
2 responses
8 views
0 likes
|
Last Post
by WHICKED
Today, 02:15 PM
|
||
Started by f.saeidi, Today, 12:14 PM
|
8 responses
21 views
0 likes
|
Last Post
by f.saeidi
Today, 01:55 PM
|
||
Started by Mikey_, 03-23-2024, 05:59 PM
|
3 responses
50 views
0 likes
|
Last Post
by Sam2515
Today, 01:47 PM
|
||
Started by Russ Moreland, Today, 12:54 PM
|
1 response
8 views
0 likes
|
Last Post Today, 01:01 PM |
Comment