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 03-21-2008, 04:58 PM   #1
Edgar V.
Member
 
Join Date: Mar 2008
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
Default Multiple Time SMA Indicator

The below example was taken from the Help Guide refering to a boolean.

protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
if (CCI(20)[0] > 200 && CCI(BarsArray[1], 20)[0] > 200
&& CCI(BarsArray[2], 20)[0] > 200)

{
// Do something
} }
}

Also, all examples seen so far explains how to do a multiple time indicator with booleans, but what I'm looking is how to code a multiple time indicator with SMAs. Example:

if SMA(5) CrossAbove SMA(10) from a 60 Min chart;
//Do something...

Also, Does NT 6.5 supports the following?:

if SMA(5) CrossAbove SMA(10) from a 60 Min chart && CCI(BarsArray[2], 20)[0] > 200)
//Do something...
Edgar V. is offline  
Reply With Quote
Old 03-22-2008, 02:23 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

There are no reference samples on multi-time framed indicators since it is currently not supported. All the multi-time frame features are currently for strategies.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-25-2008, 01:26 PM   #3
kgillis23
Member
 
Join Date: May 2007
Location: West Jordan, Utah
Posts: 61
Thanks: 0
Thanked 0 times in 0 posts
Default

Perhaps I do not clearly understand your question, but here is an example of how to do what you are asking:
Quote:
if SMA(5) CrossAbove SMA(10) from a 60 Min chart;
//Do something...
In the Initialize() method include the following statement to create a time period for your 60 Min price data (not really a chart as the only chart you will see will be the one in the time frame you run the stategy in).
Code:

Add(PeriodType.Minute,60);
Then in the OnBarUpdate() method, assuming that the above PeriodType was the first one added - so the BarsArray index will be 1. You can code your statment as:

Quote:
if (CrossAbove(SMA(BarsArray[1],5), SMA(BarsArray[1],10,1)
do something;
And this will provide a condition that will be true each time the 60 minute SMA(10) crosses above the 60 minute SMA(10), or false otherwise.

I hope this helps.
kgillis23 is offline  
Reply With Quote
Old 04-01-2008, 02:09 PM   #4
ausjreed
Junior Member
 
Join Date: Dec 2007
Posts: 7
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes you can do it with a strategy, though a little coarse.
I use DrawDot or Triangle or Diamond, once you do the Add( PeriodType.Minute, 60 ) or whatever you want in initialize.

I haven't been able to get the DrawLine to work yet but haven't spent much time with it either.

It would be nice if you could set a size for DrawDot... etc. They are too large in size now.

Also doing a draw with a strategy sets a boundary for your chart. It must remain in viewing area of chart. It would be nice if it would be allowed to scroll off the screen, then you could shrink the axis if you wanted to see it.
Sometimes another period indicator is far away from price and don't need to see it. In TradeStation you can set a flag to turn off Include All Indicators in view ( I understand that this is technically a strategy not an indicator, just using a strategy to act as surrogate indicator from anther time period )
ausjreed is offline  
Reply With Quote
Old 04-01-2008, 10:25 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

If you don't want your draw objects to influence your chart scale you will need to turn the AutoScale property on them off.
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
Multiple Instrument Indicator Kunisoft Indicator Development 12 04-14-2010 09:06 AM
MRO in indicator with multiple plots Jim-Boulder General Programming 2 01-10-2008 11:34 AM
Using multiple IB/TWS instances to maximize number of available real-time data EvolveK Automated Trading 4 01-07-2008 07:47 AM
cursor updates time position on multiple chart windows fragalles Historical NinjaTrader 6.5 Beta Threads 1 11-30-2007 02:29 AM
Multiple Time Frame access stepwise General Programming 1 03-31-2007 03:33 AM


All times are GMT -6. The time now is 07:26 AM.