![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
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);
Austin
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |