![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Aug 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
I can't seem to get multiple color on my plot. It will plot in one color only instead of changing based on the LR0 and LR1 values. I've included the code below. Can anyone point me in the right direction?
------------------------------ Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0")); ... if (LR0 > LR1) { Plots[0].Pen = new Pen(Color.Green); } if (LR0 < LR1) { Plots[0].Pen = new Pen(Color.Red); } if (LR0 == LR1) { Plots[0].Pen = new Pen(Color.Orange); } Plot0.Set (LR0); |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Plots can only have one color so you will have to employ an approach where you use two plots. Following is a referenfce sample that will show you just how to do that.
http://www.ninjatrader-support.com/v...ead.php?t=3227
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Aug 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
I used the suggested code almost verbatim. It is included below. I now get errors:
"The name "RisePlot" does not exist in the current context. Cannot apply indexing with [] to an expression of type 'double' ------------- protectedoverridevoid Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Rise")); Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Fall")); Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "Neutral")); CalculateOnBarClose = false; Overlay = false; PriceTypeSupported = false; } ///<summary> /// Called on each bar update event (incoming tick) ///</summary> protectedoverridevoid OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. ....if (LR0 > LR1) { RisePlot.Set(1, LR0[1]); RisePlot.Set(LR0[0]); } } |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Replace RisePlot with:
Value.Set(1, LR0[1]); Value.Set(LR0[0]);
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Aug 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
Ray, I've done a lot of coding in my life and this language has got to be the most esoteric and confusing one I have ever run across.
I don't understand what Value.Set does or how that will let me plot different colors based on rise, fall and neutral. Also, there must be some very subtle but strict structure necessary because now I go back to create a new version and just typing an "If" statement causes it to declare that a ";" is expected, but I'm using exactly the same statements I used earlier with success. Further to my point, I used the same statements that the example multi-color plot program used, but I get the errors I noted earlier. Goofy stuff, it is. Sigh. |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
You can tell Bill Gates that you don't like C#!
On a serious note, have you checked out our Indicator tutorials in the Help Guide?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Aug 2008
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
Touche'
By the way, I think he is no longer with Microsoft (except of course for owning the company). I'll check it out. Thanks, Paul |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
|
I just want to point out that the property Plots[x].Pen.Color is a useful way to access color x of a multi-color indicator. If you have a bunch of different colors, you will need a bunch of different plots. If you want to change the color of a price bar when one particular color (say for plot i) appears in the indicator, then
BarColor = Plots[i].Pen.Color; ...will do the trick. It's a nice way to combine an indicator and a paintbar into the same indicator. -Alex
Last edited by anachronist; 08-29-2008 at 06:56 PM.
|
|
|
|
|
|
#9 | |||
|
Senior Member
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
|
Quote:
Quote:
Quote:
-Alex
Last edited by anachronist; 08-29-2008 at 03:31 PM.
|
|||
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Thanks for the comments Alex, helpful.
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Custom plotting | bobajob78 | General Programming | 5 | 04-09-2008 01:04 PM |
| Plotting the bid/ask | lurkerlurker | NinjaScript File Sharing Discussion | 3 | 04-01-2008 03:59 PM |
| Plotting Bid and Ask volumes | fishbed | Indicator Development | 1 | 12-07-2007 10:57 AM |
| Indicator not plotting | Burga1 | Indicator Development | 11 | 12-06-2007 02:26 PM |
| PLOTTING THE BID | camelcom | Charting | 1 | 04-05-2006 12:36 AM |