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 06-13-2007, 05:52 AM   #1
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default Managing Plots for Strategy vs Presentation

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
whitmark is offline  
Reply With Quote
Old 06-13-2007, 07:18 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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
NinjaTrader_Ray is offline  
Reply With Quote
Old 06-14-2007, 06:36 AM   #3
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

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; 
    } 
}
whitmark is offline  
Reply With Quote
Old 06-14-2007, 07:25 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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.
NinjaTrader_Ray 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
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


All times are GMT -6. The time now is 12:02 AM.