NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 02-08-2010, 09:59 PM   #1
borland
Member
 
Join Date: Jan 2009
Posts: 36
Default BarsArray[] Usage Question

Normally, a simple moving average based on closing price, however if wanting it based on High from a BarsArray[], which of these is correct....

SMA(BarsArray[1].High, 20)[0]

SMA(BarsArray[1], 20).High[0]

SMA(BarsArray[1],20)[0].High

Couldn't find any examples. Thanks
borland is offline  
Reply With Quote
Old 02-09-2010, 03:33 PM   #2
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 1,760
Default

borland, you could start working with Highs[barsArrayIndex][barsAgo], which is a multi-dimensional array of all bars' highs. There is an equivalent array for all of the following: Opens, Lows, Closes, Volumes, and Times.
__________________
Austin, NinjaTrader Customer Service
NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation.

View schedule of upcoming online product training events.

NinjaTrader_Austin is offline  
Reply With Quote
Old 02-09-2010, 07:57 PM   #3
borland
Member
 
Join Date: Jan 2009
Posts: 36
Default

Thanks Austin,

Then it must be this ...

SMA(Highs[1],20)[0]

for SMA based on intrabar high, and these

SMA(BarsArray[1],20)[0]
SMA(Closes[1],20)[0]

for SMA based on closing bar price.

I now see we have Highs[], Lows[], Closes[], Opens[].

So, since Closes[] is identical to BarsArray[] when used with SMA. Why is there a BarsArray[] method?
borland is offline  
Reply With Quote
Old 02-10-2010, 08:00 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,858
Default

Correct, BarsArray[0] would for example equal Close[0] - it returns just the dataseries for the specifc bars object pointed to, while for example Closes etc would also offer a second parameter for referencing past index values of the bars object.
__________________
Bertrand, NinjaTrader Customer Service
NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation.

View schedule of upcoming online product training events.

NinjaTrader_Bertrand 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
BarsArray mballagan Miscellaneous Support 7 06-01-2009 04:20 PM
How to declare a BarsArray class? atrader General Programming 8 04-22-2009 10:22 AM
BarsArray question Jeff 15 General Programming 4 04-02-2009 11:05 AM
BarsArray properties pippero General Programming 3 09-04-2008 08:54 AM
BarsArray Intrabar Synchronization whitmark Strategy Development 2 06-27-2007 08:10 AM


All times are GMT -6. The time now is 01:53 PM.