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 > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-09-2011, 02:16 PM   #1
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default Problems with Multi time frames

The basic problem is that I cannot get an indicator to plot the same on 'Strategy Analyzer' as it does on basic Ninja charts.
The indicator in question is a simple one...EMA(20)..... that plots "barsinprogress" and draws a 5 min EMA on a 1 min chart...
(see attached 1min chart grab NinjaChart ....)

It works very well on Ninja charts and plots a line on the 1 min that is almost exactly tick for tick the same as the EMA(20) plotted on a 5min chart.

However...when I add this same indicator to a Strategy, it plots "weird".
(see attached 1min Strategy chart grab Ninja Strat)
The short 'pink lines' on the Strategy chart were drawn by me to show where the same indicator plotted values on a standard 1 min Ninja chart.....but the plotted values on the Strategy Analyzer 1 min chart are way off.

- Both use the same instrument and the same Default 24/7 session
- Both use 1 min....
- Both use the same Instrument and day range.
- Price action matches EXACTLY between both charts.

I can't figure out what is going wrong....it almost looks like the Strategy Analyzer shuts off calculations from 14:00 until 7:20in the morning... (see chart grab zNinjaStrat2)
but the Strategy is using Default 24/7....

Strategy Code is basic.... {
#region Variables
private int myInput0 = 1; // Default setting for MyInput0
#endregion

//**********************************************
protected override void Initialize()
{
Add(xcEMA15(20));
CalculateOnBarClose = true;
}


//*****************************************
protected override void OnBarUpdate()
{
// do nothing....
myInput0 = 2;
}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
Attached Images
File Type: jpg Ninjachart.jpg (86.6 KB, 4 views)
File Type: jpg Ninjastrat.jpg (102.5 KB, 3 views)
File Type: jpg zNinjaStrat2.jpg (169.3 KB, 4 views)
photog53 is offline  
Reply With Quote
Old 03-09-2011, 03:02 PM   #2
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

Hi photog53,

It's working OK here. Attached is the indicator and strategy I'm using for this. If you can post the indicator script you're using I'm happy to take a look.
Attached Files
File Type: zip MultiTimeFrameStratPlot.zip (4.5 KB, 19 views)
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-09-2011, 03:17 PM   #3
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default

Thanks for the quick reply!!

Let me take a look at the code you sent......
photog53 is offline  
Reply With Quote
Old 03-09-2011, 03:58 PM   #4
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default

Ok.... we are making progress.

Your indicator code works the same as mine...so the indicator code is not the issue.

The problem occurs when I try to use "Default 24/7" instead of "Instrument Settings".
When I switch "Session Template" to Default 24/7....both indicators have long "flat spots" between 14:00
and 07:30. Price action keeps creating bars, but both indicators 'freeze' at the value they had at 14:00 hours.

Thanks!!!

P.S. I get the same "flat spots" when I use the MultiSeriesAdding strategy...imported exactly as you sent it. My problem is something other than indicator code.
Attached Images
File Type: jpg Ninjachart3.jpg (126.1 KB, 6 views)
Last edited by photog53; 03-09-2011 at 04:02 PM.
photog53 is offline  
Reply With Quote
Old 03-09-2011, 04:21 PM   #5
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

It sounds like there may be difference in session template used.

These lines can help you track down the session template used for all series. Add the BIP0 and BIP1 lines to the indicator, and the BIP0 line to your strategy.

Print (this + "BIP0 " + BarsArray[0].Session.TemplateName);
Print (this + "BIP1 " + BarsArray[1].Session.TemplateName);
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-09-2011, 06:11 PM   #6
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default

Got it....(thanks)
photog53 is offline  
Reply With Quote
Old 03-09-2011, 06:28 PM   #7
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default

You nailed it....
EMA5Min(6E 03-11 (1 Min),20)BIP0 ind Default 24/7
EMA5Min(6E 03-11 (1 Min),20)BIP1 ind CME FX Futures RTH

So how do I get the strategy to use just one (the desired one) Session for everything?

(I say 'strategy' only because the indicator works perfectly on regular charts...
but perhaps there is extra code needed in the indicator itself)

Thanks!!!
Last edited by photog53; 03-09-2011 at 08:52 PM.
photog53 is offline  
Reply With Quote
Old 03-10-2011, 08:13 AM   #8
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default

How should I go about 'syncing' the session templates?
The answer might be simple, but I'm not finding it...

(also...if you have spare time, could you explain why the regular chart doesn't have
this issue but the Strategy Analyzer does....just so I'll know for future reference)

Thanks again for the help....
photog53 is offline  
Reply With Quote
Old 03-10-2011, 08:42 AM   #9
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

It's getting the session template from the Instrument Manager. You can change for 6E to use Default 24 / 7. The difference between the strategy analyzer and applying it directly to a chart is that the strategy does not add the series directly. The strategy is hosting the multiseries indicator. These are the following scenarios:
  • Primary series in a hosted multi-series indicator takes session template from host (chart).
  • Secondary series in a hosted multi-series indicator takes session template from instrument settings.
  • Primary series of a non-hosted multi-series indicator takes session template from chart
  • Secondary series of a non-hosted multi-series indicator takes session template from chart
NinjaTrader_RyanM is offline  
Reply With Quote
Old 03-10-2011, 09:45 AM   #10
photog53
Senior Member
 
Join Date: Feb 2010
Location: Kansas
Posts: 142
Thanks: 4
Thanked 9 times in 5 posts
Default

Thanks!!

(let me go in and see how this works....)
photog53 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
Problems with multi time frames Sangui Indicator Development 3 03-31-2011 09:37 PM
one indicator and multi time frames aytacasan Indicator Development 17 11-26-2010 05:19 AM
Problems with two time frames soyjesus Automated Trading 7 10-09-2009 02:06 PM
multi time frames price777999 Automated Trading 0 01-02-2009 02:21 PM
Multi time frames bobby1001 Strategy Development 1 07-23-2007 10:41 AM


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