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 9,014 views
    2. thumb_up 9 thanks given
    3. group 6 followers
    1. forum 14 posts
    2. attach_file 1 attachments




 
Search this Thread

Little help with Draw Region

  #11 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

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?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 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,618 since Aug 2010
Thanks Given: 1,071
Thanks Received: 5,991


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, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



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, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

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,618 since Aug 2010
Thanks Given: 1,071
Thanks Received: 5,991


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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts