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 monpere with 3 posts (1 thanks)
    3. looks_3 aligator with 3 posts (0 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 11,089 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
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,099 since Jun 2009
Thanks Given: 877
Thanks Received: 8,098

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?
Trump Media to sell instant access to market-moving soci …
Traders Hideout
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
Double Deadlock: Rubio Calls Hormuz Tolls "Unfeasib …
Traders Hideout
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #12 (permalink)
 
aligator's Avatar
 aligator 
Las Vegas, NV
Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,778 since Aug 2010
Thanks Given: 1,104
Thanks Received: 6,183


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
Legendary 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,117



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
Legendary 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,117

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
Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,778 since Aug 2010
Thanks Given: 1,104
Thanks Received: 6,183


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