NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-29-2008, 02:21 PM   #1
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Question Help with code (Zone Shading)

Hello,

I hacked together this indicator (not knowing what I am doing). I almost have it plotting the way I want it but I am missing one part that I can't figure out. I am trying to get it to shade both zones ( 2-3 std above and below an ema). See attached. I can only get the top zone shaded. Can anyone shed some light on how to shade the bottom zone?

Thanks for the help,

Tommy
Attached Images
File Type: png ER2 06-08 3_28_2008 (1 Min).png (65.7 KB, 99 views)
Attached Files
File Type: cs BBX_Zone.cs (12.2 KB, 11 views)
tommyjames is offline  
Reply With Quote
Old 03-29-2008, 02:25 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please disregard the Plot override method. Use DrawRegion() method available in NinjaTrader 6.5.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-29-2008, 02:36 PM   #3
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Default

Thanks for the reply. Do you know if there is any example code of how it would be done? I don't know much about programming, I just pasted a bunch of code together and kept tweaking it until it compiled and displayed correctly .

Thanks
tommyjames is offline  
Reply With Quote
Old 03-29-2008, 03:39 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please see the Reference Samples section in the forums: http://www.ninjatrader-support.com/v...ead.php?t=4331
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-29-2008, 08:42 PM   #5
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Default

Thanks for the info. I have it working with "DrawRegion"

In the example script the color settings and opacity settings are hard coded. Is it possible to make them user definable?
tommyjames is offline  
Reply With Quote
Old 03-30-2008, 01:16 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

You can do that just like how you would do any other variable. Please see other indicators like the SMA on how to get user definable variables.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-02-2008, 03:12 PM   #7
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Default

I have another question. I have the indicator working except every time I close and reopen NT the DrawRegion color defaults back to the default even though I changed it on the chart. I guess I missed something but i'm not sure what. Any ideas?


#region Variables
private int period = 34;
private Color FillColor = Color.Blue;
private Color XMAColor = Color.Transparent;
#endregion



DrawRegion("XMA Zone", CurrentBar, 0, EMA( High, Period ), EMA( Low, Period ), XMAColor, FillColor, 2);



Thanks
tommyjames is offline  
Reply With Quote
Old 04-02-2008, 11:35 PM   #8
spenbm01
Junior Member
 
Join Date: Nov 2004
Location: Medford, OR, USA
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Yahoo to spenbm01 Send a message via Skype™ to spenbm01
Default Drawing to the Right of last price bar

Is it possible to set 'Right side margin' to a high number (e.g., 40) and draw items in the space between the last price bar and the right side of the chart (e.g., DrawRectangle)?
spenbm01 is offline  
Reply With Quote
Old 04-03-2008, 01:20 AM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

tommyjames: The colors will be the defaults every time you use the indicator again. If you want different default colors, change it in the Variable section.

spenbm01: You currently cannot programmatically draw in the right hand region, but you can do it manually through the chart draw tools.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-03-2008, 07:32 AM   #10
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Default

Yes I understand that they will be defaults when I add the indicator to a chart but the colors default back on an existing chart with the indicator already on it. It is the only indicator that does this, so there must be something missing in the code.

Thanks
tommyjames is offline  
Reply With Quote
Old 04-04-2008, 12:13 AM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

I didn't notice anything off the bat. If you could post the indicator I can take a quick look for you to see if there truly isn't anything out of place.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-04-2008, 04:08 AM   #12
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Default

Here is the indicator....
Attached Files
File Type: cs XMAZone.cs (7.2 KB, 30 views)
tommyjames is offline  
Reply With Quote
Old 04-06-2008, 02:07 PM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

tommyjames,

Try serializing your color parameter.

After your XMA Color in the "Properties" section add this
Code:
[Browsable(false)]
public string XMAColorSerialize
{
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString(XMAColor); }
    set { XMAColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-07-2008, 11:10 AM   #14
tommyjames
Senior Member
 
Join Date: Nov 2007
Posts: 187
Thanks: 0
Thanked 1 time in 1 post
Default

Thanks for the reply. I put the code in but it still behaves the same.....

Is this a new section or is it in place of the existing section?

Any more ideas?

Thanks
Last edited by tommyjames; 04-07-2008 at 11:17 AM.
tommyjames is offline  
Reply With Quote
Old 04-07-2008, 11:36 PM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Try adding one for the FillColor also.

These should be new sections in the Properties region of your code.

That region should look like this:
Code:
        /// <summary>
        /// </summary>
        [XmlIgnore()]
        [Description("Zone Color")]
        [Category("Colors")]
        [Gui.Design.DisplayNameAttribute("Zone Color")]
        public Color fillColor
        {
            get { return FillColor; }
            set { FillColor = value; }
        }
        
        [Browsable(false)]
        public string FillColorSerialize
        {
            get { return NinjaTrader.Gui.Design.SerializableColor.ToString(FillColor); }
            set { FillColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
        }
        
        /// <summary>
        /// </summary>
        [XmlIgnore()]
        [Description("XMA Color")]
        [Category("Colors")]
        [Gui.Design.DisplayNameAttribute("XMA Color")]
        public Color xMAColor
        {
            get { return XMAColor; }
            set { XMAColor = value; }
        }
        
        [Browsable(false)]
        public string XMAColorSerialize
        {
            get { return NinjaTrader.Gui.Design.SerializableColor.ToString(XMAColor); }
            set { XMAColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
        }
        
        /// <summary>
        /// </summary>
        [Description("Numbers of bars used for calculations")]
        [Category("Parameters")]
        public int Period
        {
            get { return period; }
            set { period = Math.Max(1, value); }
        }
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Choice of Time Zone Wajodi Suggestions And Feedback 19 10-23-2008 12:55 AM
Time Zone for NT charts kgillis23 Strategy Development 10 01-19-2008 05:20 PM
Code->test/debug->change code->retest ... cycle process bbarroux Strategy Development 3 10-02-2007 12:44 PM
Zone Alarm popup? RTS Trading Automated Trading 2 05-04-2007 09:33 AM
Shading areas of chart? higler Charting 3 05-01-2007 07:58 AM


All times are GMT -6. The time now is 01:04 AM.