NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Educational Resources > Tips

Tips Official NinjaScript tips and tricks

Reply
 
Thread Tools Display Modes
Old 09-06-2007, 01:34 PM   #1
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default Adding Indicators to Strategies

When backtesting strategies it can be useful to add the indicators you use for calculations onto the chart to make it easier to check your strategy for accuracy. Instead of doing this step manually every time you run the strategy you can program it to automatically load the indicators for you.

For example:

To add a volume indicator to your charts you need to add this code snippet into the Initialize() section of your code.
Code:
Add(VOL());
To choose which panel you want your indicator plotted on you can use this code snippet into the Initialize() section:
Code:
VOLMA(20).Panel = 2;
Add(VOLMA(20));
To customize plot colors:
Code:
EMA(13).Plots[0].Pen.Color = Color.Blue;     // Plots the EMA as a blue line
To customize plot width:
Code:
EMA(13).Plots[0].Pen.Width = 2;     // Plots the EMA line with a width of 2
To customize the plot dash style:
Code:
RegressionChannel(60, 2).Plots[0].Pen.DashStyle = DashStyle.Dash;
To customize lines you can do it the same way as above.
Code:
RSI(14, 3).Lines[0].Value = 20;
RSI(14, 3).Lines[0].Pen.Color = Color.Green;
Remember, you need to use the Add() method to add your indicator if you wish to use any of plot/line indicator customizations.
NinjaTrader_Josh is offline  
Reply With Quote
The following 3 users say thank you to NinjaTrader_Josh for this post:
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
NinjaScript Strategies vs Indicators whitmark General Programming 7 08-29-2007 02:55 PM
Adding Strategies via Charts NinjaTrader_Josh Charting 1 07-28-2007 11:03 PM
Adding Indicators NinjaTrader_Josh General Programming 12 05-24-2007 12:23 PM
Missing strategies, indicators, templates BradB Installation and Licensing 2 02-12-2007 02:26 AM
adding indicators to charts traderkd Charting 2 01-24-2006 08:01 AM


All times are GMT -6. The time now is 07:08 AM.