NexusFi: Find Your Edge


Home Menu

 





Little help with Draw Region


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 5 posts (6 thanks)
    2. looks_two aligator with 3 posts (0 thanks)
    3. looks_3 monpere with 3 posts (1 thanks)
    4. looks_4 jram77 with 2 posts (1 thanks)
      Best Posters
    1. looks_one Fat Tails with 1.2 thanks per post
    2. looks_two cory with 1 thanks per post
    3. looks_3 jram77 with 0.5 thanks per post
    4. looks_4 monpere with 0.3 thanks per post
    1. trending_up 10,812 views
    2. thumb_up 9 thanks given
    3. group 6 followers
    1. forum 14 posts
    2. attach_file 1 attachments




 
Search this Thread
  #11 (permalink)
 
cory's Avatar
 cory 
virginia
the coin hunter
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,093

try DrawOnPricePanel = false, examp:


DrawOnPricePanel = false;
DrawTextFixed("Daily Volume",mystring,TextPosition.TopRight);
DrawOnPricePanel = true;


Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
$134M Ground Entry Contract in Disputed Final Review Aft …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
Expiration Day: Wall Street Rallies on Peace Hopes While …
Prediction Markets & Event Contracts
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #12 (permalink)
 
aligator's Avatar
 aligator 
Las Vegas, NV
Legendary Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,777 since Aug 2010
Thanks Given: 1,103
Thanks Received: 6,181


cory View Post
try DrawOnPricePanel = false, examp:


DrawOnPricePanel = false;
DrawTextFixed("Daily Volume",mystring,TextPosition.TopRight);
DrawOnPricePanel = true;

@cory,

Thanks a bunch, works great!


Visit my NexusFi Trade Journal Reply With Quote
  #13 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114



aligator View Post
@Fat Tails,

Can one use the Drawregion to fill between say the 30 and 70 lines on RSI indicator in indicator panel?

I tried it, but it painted inside the entire main series panel.

Thanks.

DrawRegion() can be used to fill the space

-> between two plots
-> or between a plot and a horizontal line

For your purpose, which is filling the space between two horizontal lines, I would suggest to use the NinjaScript method DrawRectangle(). The only problem with DrawRectangle() is that it plots on top of the lines plotted by the same indicator, while DrawRegion() is well behaved and draws behind.

In case that you want to fill the area behind all indicator plots and lines, which is impossible to achieve with DrawRectangle() you have two options

-> add a transparent plot which takes the constant value 30 (or 70) and then apply DrawRegion() to that plot and the other fixed line
-> add a custom plot to the indicator, which simply fills the area between the two lines

The last option is the most elegant one. You just need to code a few lines to achieve it. Below is a code snippet that you can use or modify for a custom plot.

 
Code
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
    if (Bars == null || ChartControl == null || this.LastBarIndexPainted < BarsRequired)
	 return;
    SolidBrush fillBrush = new SolidBrush(fillColor);
    int firstXToFill = ChartControl.GetXByBarIdx(BarsArray[0], this.LastBarIndexPainted);
    int lastXToFill = ChartControl.GetXByBarIdx(BarsArray[0], this.FirstBarIndexPainted);
    int yHigh = ChartControl.GetYByValue(this, 70) + (int)Lines[1].Pen.Width;
    int yLow = ChartControl.GetYByValue(this, 30);
    graphics.FillRectangle(fillBrush, lastXToFill, yHigh, firstXToFill - lastXToFill, yLow-yHigh);      
    base.Plot(graphics, bounds, min, max);
}


I have just written this down to explain the approach, I have not tested the code for bugs.


Reply With Quote
Thanked by:
  #14 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114

Alternatively, if you want to color the space between the two lines over the entire chart, you could try


 
Code
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
     if (Bars == null || ChartControl == null || this.LastBarIndexPainted < BarsRequired)
          return;
     SolidBrush fillBrush = new SolidBrush(fillColor);
     int firstXToFill = ChartControl.Bounds.Right;
     int lastXToFill = ChartControl.Bounds.Left;
     int yHigh = ChartControl.GetYByValue(this, 70) + (int)Lines[1].Pen.Width;
     int yLow = ChartControl.GetYByValue(this, 30);
     graphics.FillRectangle(fillBrush, lastXToFill, yHigh, firstXToFill - lastXToFill, yLow-yHigh);      
     base.Plot(graphics, bounds, min, max);
}


I assume that you declare fillColor in the variables section and also declare a property allowing you to change it.


Reply With Quote
Thanked by:
  #15 (permalink)
 
aligator's Avatar
 aligator 
Las Vegas, NV
Legendary Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,777 since Aug 2010
Thanks Given: 1,103
Thanks Received: 6,181


Fat Tails View Post
Alternatively, if you want to color the space between the two lines over the entire chart, you could try


 
Code
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
     if (Bars == null || ChartControl == null || this.LastBarIndexPainted < BarsRequired)
          return;
     SolidBrush fillBrush = new SolidBrush(fillColor);
     int firstXToFill = ChartControl.Bounds.Right;
     int lastXToFill = ChartControl.Bounds.Left;
     int yHigh = ChartControl.GetYByValue(this, 70) + (int)Lines[1].Pen.Width;
     int yLow = ChartControl.GetYByValue(this, 30);
     graphics.FillRectangle(fillBrush, lastXToFill, yHigh, firstXToFill - lastXToFill, yLow-yHigh);      
     base.Plot(graphics, bounds, min, max);
}


I assume that you declare fillColor in the variables section and also declare a property allowing you to change it.

@Fat Tails,

Most helpful, Thank you!


Visit my NexusFi Trade Journal Reply With Quote




Last Updated on September 25, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts