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 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-07-2012, 10:38 AM   #1
jmflukeiii
Senior Member
 
Join Date: Dec 2011
Posts: 190
Thanks: 16
Thanked 6 times in 6 posts
Default Summation of previous bars

Can someone point me in the right direction to learn how to create a loop (or whatever is necessary) to do the following:

While a certain condition is met, add the result of an indicator (such as volume) on each successive bar and store it as a double or int that can be plotted.

Thank you for any tips.
jmflukeiii is offline  
Reply With Quote
Old 07-07-2012, 12:12 PM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,201
Thanks: 24
Thanked 1,227 times in 998 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by jmflukeiii View Post
Can someone point me in the right direction to learn how to create a loop (or whatever is necessary) to do the following:

While a certain condition is met, add the result of an indicator (such as volume) on each successive bar and store it as a double or int that can be plotted.

Thank you for any tips.
Though you could use a loop, that looks like a straight accumulation scheme is what you need: loops are generally inefficient, and I avoid them if I can find another method.

Code:
 
private double TotalSum = 0;
Code:
 
bool ConditionMet = false;
 
// code to evaluate and set ConditionMet goes here
 
if (ConditionMet)  TotalSum += Volume[0];
else TotalSum = 0;
For Volume, you probably do want to use int: double is just a more general illustration of the principle.
koganam is offline  
Reply With Quote
The following 2 users say thank you to koganam for this post:
Old 07-07-2012, 12:20 PM   #3
jmflukeiii
Senior Member
 
Join Date: Dec 2011
Posts: 190
Thanks: 16
Thanked 6 times in 6 posts
Default

koganam, as always, thank you for your help
jmflukeiii is offline  
Reply With Quote
Old 07-07-2012, 01:13 PM   #4
jmflukeiii
Senior Member
 
Join Date: Dec 2011
Posts: 190
Thanks: 16
Thanked 6 times in 6 posts
Default

If I have an indicator that plots both in a separate indicator panel (using plots) and then places lines on the chart, how do I set this up in the script?

Thank you

EDIT: With a quick search, it looks like that is not possible. I'll create two indicators
Last edited by jmflukeiii; 07-07-2012 at 01:16 PM.
jmflukeiii is offline  
Reply With Quote
Old 07-07-2012, 03:35 PM   #5
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,201
Thanks: 24
Thanked 1,227 times in 998 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by jmflukeiii View Post
If I have an indicator that plots both in a separate indicator panel (using plots) and then places lines on the chart, how do I set this up in the script?

Thank you

EDIT: With a quick search, it looks like that is not possible. I'll create two indicators
Look up DrawOnPricePanel.
koganam 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
getting color of previous bars ziggymeister Strategy Development 1 11-16-2011 02:10 AM
Color previous bars pauly139 Indicator Development 2 03-28-2011 11:49 AM
summation High/summation bar K. SATO General Programming 3 05-03-2010 05:53 AM
Summation (SUM) jcash General Programming 29 07-27-2009 07:10 AM
Data from previous bars stljeffbb Miscellaneous Support 2 08-01-2008 11:32 PM


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