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-05-2012, 09:28 PM   #1
negativezero
Junior Member
 
Join Date: Mar 2011
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
Default Multi-Time-Frame Strategy

Hello, I am wondering if I could do this in NinjaTrader:

Basically I want to add different time frame in my automated trading strategy along with some indicators for those time frames ( SMAs in this case)

I did a backtesting on this strategy, it seems to give some crazy results.

Code:
protected override void Initialize()
        {
			 // Trading frame
            Add(PeriodType.Tick, 144);  // BarsArray[1]

            // Add a 5 minute Bars object to the strategy
            Add(PeriodType.Minute, 3);  // BarsArray[2]

            // Add a 15 minute Bars object to the strategy
            Add(PeriodType.Minute, 10); // BarsArray[3]

            // Add a 30 minute bar object to the strategy
            Add(PeriodType.Minute, 30); // BarsArray[4]

            // Note: Bars are added to the BarsArray and can be accessed via an index value
            // E.G. BarsArray[1] ---> Accesses the 5 minute Bars object added above

            // Add simple moving averages to the chart for display
            // This only displays the SMA's for the primary Bars object on the chart
            Add(SMA(BarsArray[1], 15));
            Add(SMA(BarsArray[1], 89));

            Add(SMA(BarsArray[2], 20));
            Add(Stochastics(BarsArray[2],7,14,3));

            Add(SMA(BarsArray[3], 20));
            Add(Stochastics(BarsArray[3],7,14,3));
			
            CalculateOnBarClose = false;
        }
negativezero is offline  
Reply With Quote
Old 02-06-2012, 12:26 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

negativezero, that can be done with NinjaScript, however you would need to be mindful about the OnBarUpdate() then be called for each bars object added if you don't take care to filter them through BarsInProgress -

http://www.ninjatrader.com/support/h...inprogress.htm

BarsArray will only let you define what bars object data to use, but not when to do this call, so the event timing.
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
Multi time frame strategy Nuno Renato Strategy Development 11 01-27-2011 12:58 PM
multi-time frame strategy rogueTrader Strategy Development 1 01-25-2011 08:59 AM
Multi-Instrument Multi-Time frame strategy Shansen Strategy Development 1 12-28-2009 06:09 AM
Multi-time frame strategy laparker Strategy Development 4 05-24-2009 10:03 PM
Multi-time frame strategy - Longer-term real-time calculations Shansen Strategy Development 1 04-19-2009 06:36 AM


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