if (CCIPlot[0] > obLevelE) { Draw.Region(this, "CCIup", CurrentBar, 0, CCIPlot, obLevelE, Brushes.Red, opacity4, Displacement); } if (CCIPlot[0] < osLevelE) { Draw.Region(this, "CCIdn", CurrentBar, 0, CCIPlot, osLevelE, Brushes.Lime, opacity4, Displacement); }
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
If something wrong with Draw.Region?
Collapse
X
-
If something wrong with Draw.Region?
I am trying to get the region to only fill when the CCI value exceeds my defined value, yet it colors the area below as well regardless how I try to stop it from doing so. I've included a snippet for what I believe should trigger it to shade red if its over my overbought level, and lime if its under my oversold level. Can you please help me sort out why this would not work as intended?
Code:Last edited by Conceptzx; 01-24-2024, 05:34 AM.Tags: None
-
Hello Conceptzx,
Thank you for your post.
In both Draw.Region() methods, you have the startBarsAgo set to "CurrentBar" barsAgo and the endBarsAgo set to 0 barsAgo. This means the region will be drawn for every bar on the chart up to that bar where the condition was triggered. Each time the condition is triggered again, the existing Region object is updated to draw across all bars on the chart again. You mentioned you want it to, "only fill when the CCI value exceeds my defined value" - do you mean you only want it to fill for the bars on which the CCI is above/below the value? Please clarify what you are looking to achieve so I may better understand and assist you.
I look forward to your reply.Emily C.NinjaTrader Customer Service
Comment
-
Originally posted by Conceptzx View PostIn the attached image where CCI exceeds my defined value, I only want it to fill red between the plot and the line while above the line, not from below the line to the plot.
A similar scenario has been discussed in the following thread:
Hello, I'm trying to draw a region whose color will depend on whether an indicator line is higher or lower than another indicator line. It just keeps giving me the same color, though. Could you please tell me what is incorrect with this syntax? I've simplified the issue with the following sample. I would be most grateful
As mentioned in that thread, there is an example indicator that uses different colored regions for different conditions. This indicator is publicly available on our NinjaTrader Ecosystem website:
Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:
Note — To import NinjaScripts you will need the original .zip file.
To Import:- Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
- From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
- Select the downloaded .zip file
- NinjaTrader will then confirm if the import has been successful.
Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'
Once installed, you may add the indicator to a chart by:- Right-click your chart > Indicators... > Select the Indicator from the 'Available' list on the left > Add > OK
Here is a short video demonstration of the import process:
Please let me know if I can be of further assistance.
The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
Emily C.NinjaTrader Customer Service
Comment
-
The CCI logic is built into this indicator, its not calling on the original CCI to calculate the plot.
I'm still confused here, are you suggesting something like this?
Code:if (CCIPlot[0] < obLevelE && CCIPlot[0] > osLevelE) { Draw.Region(this, "CCIneu", CurrentBar, 0, CCIPlot, obLevelE, Brushes.Transparent, 100, Displacement); Draw.Region(this, "CCIned", CurrentBar, 0, CCIPlot, osLevelE, Brushes.Transparent, 100, Displacement); } else if (CCIPlot[0] > obLevelE) { Draw.Region(this, "CCIup", CurrentBar, 0, CCIPlot, obLevelE, Brushes.Red, opacity4, Displacement); } else if (CCIPlot[0] < osLevelE) { Draw.Region(this, "CCIdn", CurrentBar, 0, CCIPlot, osLevelE, Brushes.Lime, opacity4, Displacement); }
Comment
-
Originally posted by Conceptzx View PostThe CCI logic is built into this indicator, its not calling on the original CCI to calculate the plot.
I'm still confused here, are you suggesting something like this?
Code:if (CCIPlot[0] < obLevelE && CCIPlot[0] > osLevelE) { Draw.Region(this, "CCIneu", CurrentBar, 0, CCIPlot, obLevelE, Brushes.Transparent, 100, Displacement); Draw.Region(this, "CCIned", CurrentBar, 0, CCIPlot, osLevelE, Brushes.Transparent, 100, Displacement); } else if (CCIPlot[0] > obLevelE) { Draw.Region(this, "CCIup", CurrentBar, 0, CCIPlot, obLevelE, Brushes.Red, opacity4, Displacement); } else if (CCIPlot[0] < osLevelE) { Draw.Region(this, "CCIdn", CurrentBar, 0, CCIPlot, osLevelE, Brushes.Lime, opacity4, Displacement); }
Draw.Region(this, "reg1" + sb1, CurrentBar - sb1 + 1, 0, Upper, Lower, Brushes.Transparent, wideColor, opacity, Displacement);
Additionally, the regions do not start at the beginning of the chart and end on the current bar. You will need to indicate which bar you would like the regions to start on, which is when the crossover occurs.
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jimmyk, 01-26-2018, 05:19 AM
|
6 responses
835 views
0 likes
|
Last Post
by emuns
Today, 11:27 AM
|
||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
6 responses
3,291 views
1 like
|
Last Post
by jgualdronc
Today, 10:56 AM
|
||
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
11 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
11 responses
62 views
0 likes
|
Last Post Today, 10:08 AM | ||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 09:55 AM |
Comment