![]() |
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 |
|
Certified NinjaScript Consultant
|
I have a custom indicator that drives out only one value but uses two plots to implement differential coloring based on certain conditions. For example, If the indicator value is moving up or flat, the green plot1 is set, else the red plot2 is set. Now, if I want to use that value from the indicator in a strategy, I would need to merge the values from both plots 1 and 2 into a single dataseries to get a single value for each bar. Alternatively, I could push a 3rd plot from the indicator where the value is set at the close of each bar, but the plot color would need to be set to transparent. Hopefully this shows that plotting techniques for visual presentation may differ from those used to pass a data series to a strategy.
Can you offer any best practices, over and above what I have shared here, for how best to address these two objectives simultaneously? I assume it is better to have fewer plots and fewer dataseries for processing efficiency. For example, is overriding a single Plot to manage plot color and push out a single dataseries more efficient than bifurcating several plots to do the same, when ultimately strategy processing and optimization will be involved. Thanks. Regards, Whitmark |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Adding an additional plot likely will not have a performance impact. However, what I would do is have a new DataSeries object and expose that.
For example: private DataSeries mySeries; In Initialize(): mySeries = new DataSeries(this); Set the values for each bar in OnBarUpdate() Then expose a property for it: public DataSeries MySeries { get { Update(); // This is important return mySeries; } } See here for info on Update() http://www.ninjatrader-support.com/H...V6/Update.html
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Certified NinjaScript Consultant
|
Thanks Ray . . . this is just the technique I was looking for to be able to pass dataseries values between indicators and strategies without necessarily adding more plots that would appear in the indicator panel.
One follow-up question, however. When I compare the approach you recommend with the example in the help under update() that is shown below, I see that the latter did not require a dataseries to be passed. Are there instances where you would prefer to use one approach vs the other? In my case, I would like to be able to refer back to previous barsago values in the dataseries from within the strategy. Thanks. Code:
tripleValue = 0;
private double
protected override void OnBarUpdate()
{
if (CurrentBar < 20)
return;
tripleValue = SMA(20)[0] * 3;
Values[0].Set(SMA(20)[0]);
}
public double TripleValue
{
get
{
Update();
return tripleValue;
}
}
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Rule of thumb is if you need to store data on each bar then use a DataSeries, if you only need to know the current state, use any data type.
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing Multiple Custom Indicator Plots within a Strategy | whitmark | Strategy Development | 15 | 03-28-2009 04:21 PM |
| Multi Colored plots. | higler | General Programming | 6 | 05-10-2007 12:05 PM |
| Adding Plots | rt-trader | General Programming | 5 | 02-09-2007 01:01 AM |
| Plots[?].Min & Plots[?].Max Don't work | AlohaBob | Indicator Development | 6 | 01-06-2007 08:31 PM |
| Managing positions | bermuda | Miscellaneous Support | 1 | 05-01-2005 09:23 AM |