NinjaTrader Support Forum  

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 05-10-2008, 02:12 PM   #1
snaphook
Senior Member
 
Join Date: Apr 2008
Posts: 376
Thanks: 0
Thanked 20 times in 11 posts
Default One indicator, two functions

I am trying to develop an indicator with a plot and data trapping. I would like the plot to be continuous intrabar and the data trap to be at bar close, trapping the plot closing values depending on signals/variables generated by the plot, so not every bar would be trapped. Is there a way to have one function running intrabar with a second running at bar close?

If not, is there a way for one indicator function (the data trap) to access signals/variables from a second indicator (the plot). I hate to have a second indicator calculating the same thing as the first, just so it can trap at bar close, but monitoring variables in the first might not be so cpu intensive.

Many thanks,
snap
snaphook is offline  
Reply With Quote
Old 05-10-2008, 02:38 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You can do this by limiting code segments in your code with this if statement:
Code:
if (FirstTickOfBar)
Code inside this will be equivalent to running at the close of each bar while code outside will be evaluated at every tick update if CalculateOnBarClose to false is set.

While you are inside the if-statement make sure you are using an index value of [1] to get to the just closed bar's values though. For instance everything should be applied to Close[1], Open[1], etc. If you forget to do this you will be getting the values of the first tick of the new bar instead of the values of the closed bar.
Last edited by NinjaTrader_Josh; 05-10-2008 at 06:20 PM.
NinjaTrader_Josh 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
renaming functions z32000 General Programming 3 12-03-2007 10:47 AM
Order functions gert74 Strategy Development 1 06-27-2007 01:20 AM
Accessing Custom Indicator Functions in Strategies ThePatientOne Strategy Development 1 05-29-2007 01:29 PM
Creating NinjaTrader compatible functions from TS ShowMe and indicator email alerts robinso Miscellaneous Support 1 04-11-2007 05:33 PM
using DLL interface functions in c# Futures_Shark Automated Trading 4 01-03-2007 02:17 AM


All times are GMT -6. The time now is 05:56 PM.