NexusFi: Find Your Edge


Home Menu

 





PlotColors Code for NT7


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 5 posts (2 thanks)
    2. looks_two eDanny with 4 posts (1 thanks)
    3. looks_3 jharthun with 2 posts (1 thanks)
    4. looks_4 cory with 1 posts (2 thanks)
      Best Posters
    1. looks_one cory with 2 thanks per post
    2. looks_two jharthun with 0.5 thanks per post
    3. looks_3 Fat Tails with 0.4 thanks per post
    4. looks_4 eDanny with 0.3 thanks per post
    1. trending_up 5,532 views
    2. thumb_up 7 thanks given
    3. group 4 followers
    1. forum 13 posts
    2. attach_file 3 attachments




 
Search this Thread

PlotColors Code for NT7

  #1 (permalink)
 
jharthun's Avatar
 jharthun 
Hacienda Heights, CA
 
Experience: Intermediate
Platform: NinjaTrader 8
Broker: NinjaTrader Brokerage
Trading: MCL, M2K, MNQ, MES
Posts: 50 since Jul 2009
Thanks Given: 14
Thanks Received: 32

I have a colored plot that crosses a zero line. The colors do not change exactly at the zero line. How should this be coded to change exactly at the zero line?

if (Plot[0]>0) PlotColors[0][0] = UpColor;
if (Plot[0]<0) PlotColors[0][0] = DownColor;

I would also like the zero line and other lines to draw on top of a histogram instead of behind. Is that possible?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Increase in trading performance by 75%
The Elite Circle
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Tao te Trade: way of the WLD
23 thanks
Diary of a simple price action trader
22 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #3 (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



jharthun View Post
I have a colored plot that crosses a zero line. The colors do not change exactly at the zero line. How should this be coded to change exactly at the zero line?

if (Plot[0]>0) PlotColors[0][0] = UpColor;
if (Plot[0]<0) PlotColors[0][0] = DownColor;

I would also like the zero line and other lines to draw on top of a histogram instead of behind. Is that possible?

Best attach a sample, so we can modify it.

If you want to plot the zeroline and other lines on top of a histogram, this is possible but not easy. You need to use ZOrder, and code two indicators.

Use one indicator for the histogram, select Zorder = x (for example ZOrder = 2) in the Initialize() section of the indicator.
Use another indicator for the zerolines, select ZOrder = x+1 (for example ZOrder = 3) in the Initialize() section of the indicator.

As far as I know, it is not possible to code this within a single indicator.



where x stands for a number such as 2

Reply With Quote
  #4 (permalink)
 
eDanny's Avatar
 eDanny 
East Rochester, NY
 
Experience: Intermediate
Platform: NT
Posts: 329 since Jul 2009
Thanks Given: 18
Thanks Received: 425

Post the code and I'll fix you up.

Reply With Quote
  #5 (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


eDanny View Post
Post the code and I'll fix you up.

Do you have a solution for the problem to draw one element on top of another within the same indicator? For example, woud it be possible to draw a rectangle via DrawRectangle() behind a plotted line?

Reply With Quote
  #6 (permalink)
 
jharthun's Avatar
 jharthun 
Hacienda Heights, CA
 
Experience: Intermediate
Platform: NinjaTrader 8
Broker: NinjaTrader Brokerage
Trading: MCL, M2K, MNQ, MES
Posts: 50 since Jul 2009
Thanks Given: 14
Thanks Received: 32

Hi Fat Tails

I found a solution for drawing a line on top of a histogram. Instead of using Add(Line), I used Add(Plot) and set it to a fixed value. As long as the horizontal line plot comes before the histogram plot, the line draws on top.

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
tarantino
Willowbrook, IL
 
Posts: 32 since Sep 2010
Thanks Given: 71
Thanks Received: 39


Fat Tails View Post
Do you have a solution for the problem to draw one element on top of another within the same indicator? For example, woud it be possible to draw a rectangle via DrawRectangle() behind a plotted line?


protectedoverridevoid OnBarUpdate()
{
IRectangle r = DrawRectangle(
"r", true, CurrentBar, Close[0] - 4 * TickSize, 0, Close[0] + 4 * TickSize, Color.Red, Color.Red, 8);
r.SeparateZOrder =
true;
Value.Set(Close[
0]);
}

It will not allow you to set ZOrder in the code, but at least you can change it with
Shift + Mouse Wheel when on the chart...

Reply With Quote
  #8 (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


tarantino View Post
protectedoverridevoid OnBarUpdate()
{
IRectangle r = DrawRectangle(
"r", true, CurrentBar, Close[0] - 4 * TickSize, 0, Close[0] + 4 * TickSize, Color.Red, Color.Red, 8);
r.SeparateZOrder =
true;
Value.Set(Close[
0]);
}

It will not allow you to set ZOrder in the code, but at least you can change it with
Shift + Mouse Wheel when on the chart...

That is already better than 2 separate indicators that I have used so far. The question is, whether I can save the order as part of my workspace, once I have shifted it to the appropriate level. The chart template does not save it, as far as I know.

Reply With Quote
  #9 (permalink)
 
eDanny's Avatar
 eDanny 
East Rochester, NY
 
Experience: Intermediate
Platform: NT
Posts: 329 since Jul 2009
Thanks Given: 18
Thanks Received: 425


Fat Tails View Post
Do you have a solution for the problem to draw one element on top of another within the same indicator? For example, woud it be possible to draw a rectangle via DrawRectangle() behind a plotted line?

Yes, the solution is in post #6.

Reply With Quote
  #10 (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



eDanny View Post
Yes, the solution is in post #6.

I have modified the pivots indicator and added 3 lines of code to plot a rectangle as well. The rectangle is plotted in the end of the OnBarUpdate() section.

- I have not yet tried to put DrawRectangle() into the custom plot area, because the custom plot is called with every incoming tick... -

As can be seen below, the rectangle plots above the bars and above the plot lines. If I initialize the indicator with ZOrder = -1, the rectangle will plot behind the bars, but still above the plot lines.

Is there any way to plot the rectangle behind the plot lines?

Attached Thumbnails
Click image for larger version

Name:	TF 12-10 (15 Min)  17_11_2010.jpg
Views:	302
Size:	84.7 KB
ID:	25806  
Attached Files
Elite Membership required to download: RectanglePivots.zip
Reply With Quote
Thanked by:




Last Updated on November 16, 2010


© 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