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 06-13-2012, 12:15 PM   #16
kinshin9
Member
 
Join Date: Oct 2011
Posts: 40
Thanks: 14
Thanked 4 times in 4 posts
Default

Adam/Ryan,

need to know two things:
1. As I explained above about my MA/indicator , If I've 10 stocks (rows) and 5 columns (5m/15m...)
how many instances of my indicator will be runing ?.
2. I need to run the pivot check to do a calculation but only once I need to do this, how do I control this in onBarUpdate() only once per session, if possible.
here is the code I'm using as a call in the onBarUpdate()

private void getPivotValue(){

if (Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP.ContainsValue(0))
{
// Prints the current pivot point value
pivotPP = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
Print(Instrument.MasterInstrument.Name+"pivot is " + pivotPP.ToString());

}
}// end
kinshin9 is offline  
Reply With Quote
Old 06-13-2012, 12:28 PM   #17
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

1) A separate instance will be created for each instrument and interval. Looks like 50 in your case.

2) Any calculations that you need done only once per session could be done during Bars.FirstBarOfSession
http://www.ninjatrader.com/support/h...rofsession.htm
Last edited by NinjaTrader_RyanM; 06-13-2012 at 12:31 PM.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-01-2012, 04:05 PM   #18
kinshin9
Member
 
Join Date: Oct 2011
Posts: 40
Thanks: 14
Thanked 4 times in 4 posts
Default

need a little help with the multi-time coding:
instead of accessing/checking with BarsInProgress flag can I use BarsPeriod.Value flag to check and
process ?.
kinshin9 is offline  
Reply With Quote
Old 07-02-2012, 03:03 AM   #19
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
Default

Unfortunately BarsInProgress can't be substituted by checks to the BarsPeriod - you would need to know which series triggered the OnBarUpdate() call and this feedback is received with BarsInProgress.
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 07-07-2012, 10:47 PM   #20
kinshin9
Member
 
Join Date: Oct 2011
Posts: 40
Thanks: 14
Thanked 4 times in 4 posts
Default

all i have in my strategy to draw an arrow if it is an end of session bar. but it is only drawing for last 30 days where i have 44 days loaded in my chart.I set the lookback period to infinite, must be missing a simple thing. help
kinshin9 is offline  
Reply With Quote
Old 07-09-2012, 07:08 AM   #21
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

kinshin9 - Sorry not sure. Please feel free to post a screenshot of your chart and a simple code snippet showing what you're trying to do.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-09-2012, 07:06 PM   #22
kinshin9
Member
 
Join Date: Oct 2011
Posts: 40
Thanks: 14
Thanked 4 times in 4 posts
Red face

Ryan,

here is the simple code and attached is the image, drawing Magenta down arrow at every end of the session bar starting from 7/8 until 6/21 and ignoring the earlier days. I even made look back to infinite
in my strategy.
here is the code:
if(Bars.LastBarOfSession)
DrawArrowDown("dwnarrow"+ CurrentBar , false, 0, High[0]+0.3, Color.Magenta);
Attached Images
File Type: jpg CMG (60 Min) 7_9_2012.jpg (194.9 KB, 11 views)
kinshin9 is offline  
Reply With Quote
Old 07-10-2012, 07:40 AM   #23
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello kinshin9,
Please change the BarsRequired property to say 0 (zero) from the default 20 and see if you are still getting the same result or not.

Please refer to our help guide to know more about it.
http://www.ninjatrader.com/support/h...rsrequired.htm
NinjaTrader_Joydeep is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Joydeep for this post:
Old 07-10-2012, 09:13 AM   #24
kinshin9
Member
 
Join Date: Oct 2011
Posts: 40
Thanks: 14
Thanked 4 times in 4 posts
Default

thought missing something simple. thanks, it worked.
kinshin9 is offline  
Reply With Quote
The following user says thank you to kinshin9 for this post:
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
high of the most recent bars gotet0 Automated Trading 2 10-20-2011 08:37 PM
Best way to get PnL of most recent trade? mgbloomfield Automated Trading 2 05-05-2008 08:26 PM
most recent Beta nicko9 Installation and Licensing 1 01-24-2008 03:08 AM
Most recent trade Jim-Boulder Strategy Development 2 07-16-2007 07:15 PM
Most Recent Occurence NinjaTrader_Ray General Programming 3 02-19-2007 08:34 AM


All times are GMT -6. The time now is 10:55 AM.