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 Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 08-19-2010, 02:27 PM   #1
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default Plotting newbie question

I have read through best I can on plotting (NT7b20) and this is what I understand and what I am trying to do in a strategy:

protected override void Initialize()
{
Add(EMA(11)); // plots the moving average continuously
//
// adds a StrategyPlot indicator to paint the 'stop loss' with.
Add(StrategyPlot(0));
StrategyPlot(0).Plots[0].Pen.Color = Color.Black;
StrategyPlot(0).Plots[0].PlotStyle = PlotStyle.Square;
StrategyPlot(0).PanelUI = 1;
StrategyPlot(0).Name = "StopLoss";
} // so that is all fine

// but I only want to have plotting completed on certain conditions as:

protected override void OnBarUpdate()
{ // this condition
if (EMA(11)[0] > (EMA(5)[0] // does not
{ // plot something somehow} //have a way of plotting

// and this condition
while (EMA(11)[0] > (EMA(5)[0] // also does not
{ // plot something somehow} //have a way of plotting

}
// so what can I use in OnBarUpdate to plot on certain conditions

TIA,
Jon
Last edited by Trader.Jon; 08-19-2010 at 02:30 PM.
Trader.Jon is offline  
Reply With Quote
Old 08-19-2010, 02:34 PM   #2
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Jon, you could use a plot, but there are also quite a few different drawing objects you could place on the chart, like squares, dots, triangles, arrows, diamonds, etc. So if you wanted to place arrows on each crossover, for example, you could do something like this:
Code:
if (CrossAbove(EMA(5), EMA(11), 1))
                DrawArrowUp("up arrow" + CurrentBar, false, 0, Low[0] - 2 * TickSize, Color.Green);
if (CrossBelow(EMA(5), EMA(11), 1))
                DrawArrowDown("down arrow" + CurrentBar, false, 0, High[0] + 2 * TickSize, Color.Red);
I actually have a script laying around that does just this.. I've attached it for your convenience.
Attached Images
File Type: png mscrosses.PNG (56.4 KB, 8 views)
Attached Files
File Type: zip ShowMACrosses.zip (3.8 KB, 5 views)
NinjaTrader_Austin 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
Newbie question yawbus General Programming 5 02-18-2010 11:09 AM
Newbie question blarouche Indicator Development 1 04-08-2009 04:43 AM
Newbie-where to start-plotting a few things InvGrp Indicator Development 1 03-13-2009 06:21 AM
newbie question j4068 Miscellaneous Support 1 03-08-2009 07:04 PM
newbie question machiavelly Charting 5 01-02-2009 06:10 AM


All times are GMT -6. The time now is 02:30 PM.