NinjaTrader Support Forum  

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 01-03-2008, 12:05 AM   #1
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Question Multi time frame syncronize chart with strategy

Scenario:

I have a strategy that uses multi time frames.
For example it also reads: 1 minute and 3 minute

The 1 minute is ok because all charts are always the same.
However the 3 minute is not the same. The 3 minute can begin in any of 3 continuous minutes. Like a tick chart it can begin with any tick.

Is there any way to synchronize a chart with a timeframe used in a strategy?

What I am looking at on a chart is not the same as the strategy uses. I understand why but it drives me crazy when I look at my signals and try to figure out what happened. I look at one chart but the strategy uses a totally different chart in essence.

I tried using the same days back on all timeframe charts but it didn't help.

It would be nice if you could see an actual charts that are sync for a strategy.

Regards

Cliff
ct is offline  
Reply With Quote
Old 01-03-2008, 12:24 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Are you referring to how the bars are being built as outlined here? http://www.ninjatrader-support.com/H...struments.html

You could try making the 3min bars your primary bars so you can see those for your signals?
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-03-2008, 12:57 AM   #3
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Default

Josh

I see you got the late shift again.

Understood on the 3 minute primary but I also use a very small volume chart and it is the one that needs to be the primary so I am looking at the smallest chart I am getting signals from.

So there is no way to sync a chart of an added timeframe to a strategy?

I understand they all swing on a different clock I just didn't know if I can see what the strategy sees.
ct is offline  
Reply With Quote
Old 01-03-2008, 01:01 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

I forget how the exact behavior goes. Let me run some tests on my end and let you know.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-03-2008, 02:03 AM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi ct,

I believe things should be in sync for you as is. Please take a look at my attached test strategy. You will find the bar data is printed accurately and in sync with the multiple time frames.

I suspect if you are using a custom indicator you may need to use Update() to keep the values in sync. http://www.ninjatrader-support.com/H...V6/Update.html
Attached Images
File Type: jpg 1.jpg (97.1 KB, 44 views)
Attached Files
File Type: zip multitimeframetest.zip (790 Bytes, 28 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-03-2008, 02:25 AM   #6
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Default

Josh


No custom indicators used.

That may be some of the issue. I had a signal where the strategy said the macd on the 5 minute timeframe was up. I went 5 bars+ either side of the signal time and it was always down but I still got an up signal. Below is the code that is checked.

I know I can use rising or falling but it doesn't work well for multi time frames so I never use it. Been burned bad. Wounds are healed but left bad scars.

_required.Add(delegate()
{
return (s.MACD(19,38,9)[0] > s.MACD(19,38,9)[1]
&& s.MACD(s.BarsArray[s.InstrumentPosition["1-Minute"]],19,38,9)[0] > s.MACD(s.BarsArray[s.InstrumentPosition["1-Minute"]],19,38,9)[1]
&& s.MACD(s.BarsArray[s.InstrumentPosition["5-Minute"]],19,38,9)[0] > s.MACD(s.BarsArray[s.InstrumentPosition["5-Minute"]],19,38,9)[1]
)

;
});

Will see if your mod helps....
ct is offline  
Reply With Quote
Old 01-03-2008, 02:33 AM   #7
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Question

Josh

I sent you some screen shots via support ticket system.Ticket number is 56159.

If I am not using a custom indicator can I still have multi timeframe data issues?
ct is offline  
Reply With Quote
Old 01-03-2008, 02:36 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi ct,

I currently do not have direct access to the ticket system. If you don't mind could you send me the screenshots directly? josh [at] ninjatrader [dot] com. Thanks.

I believe the issue is not data per se. It is just that under certain situations a custom indicator may not be kept up to date with the current bar being processed.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-03-2008, 02:41 AM   #9
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Question

Josh

Ticket email forwarded.

If I have 3 timeframes all using the same instrument and I am using CalculateOnBarClose = false; should I only perform my calcs on BarsInProgress == 3? Since it is 3rd will it always be called last (after 1 and 2 are updated) if using the same instrument?

Could be part of my problem but not all of it.
ct is offline  
Reply With Quote
Old 01-03-2008, 02:45 AM   #10
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Exclamation Ninja Release

Josh

Forgot to mention I am on 6.5.0.4.

Cliff
ct is offline  
Reply With Quote
Old 01-03-2008, 02:48 AM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

It would be easier on your coding to run your calculations on only the last bar series, but you do not need to necessarily restrict yourself in that manner. If you have a need to run calculations in other bars you can.

I'm reviewing your screenshots right now along with the code snippet you provided. The only thing I can think of is for you to check if s.InstrumentPosition["5-Minute"] is actually giving you the correct bar object.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-03-2008, 02:53 AM   #12
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Default

Is should be the correct bar object:


Add(PeriodType.Minute, 1);
InstrumentPosition.Add("1-Minute", 1);
Add(PeriodType.Minute, 1);
InstrumentPosition.Add("5-Minute", 2);
Add(PeriodType.Volume, 500);
InstrumentPosition.Add("500-Volume", 3);
ct is offline  
Reply With Quote
Old 01-03-2008, 02:57 AM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Give me a moment. I accidentally destroyed my NT6.5 environment and need to rebuild it before I can test some stuff for you.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-03-2008, 02:58 AM   #14
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Default

When I reference another timeframe I always do it explicitly and specify the bars array. It makes it easier for me to keep track of. Otherwise you are saving values from each onbarupdate to compare once you have them all collected.
ct is offline  
Reply With Quote
Old 01-03-2008, 03:01 AM   #15
ct
Senior Member
 
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 358
Thanks: 1
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by Josh View Post
Give me a moment. I accidentally destroyed my NT6.5 environment and need to rebuild it before I can test some stuff for you.

ok, I am going to get a few hours sleep. I have been trying to resolve this issue for a while. I am beat.
ct 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
CurrentBar and Multi Time Frame maxpi Strategy Development 7 07-31-2009 01:07 PM
Multi-time frame scjohn Strategy Development 1 06-06-2007 07:20 PM
Accessing High value in a multi time frame strategy PrTester Strategy Development 4 05-02-2007 01:13 AM
Strategy Analyzer Chart Displays Too Much When Time Frame is Changed KBJ Strategy Analyzer 1 04-23-2007 07:30 AM
Plotting values on multi-time frame and instruments chart SuzyG Strategy Development 1 01-19-2007 12:32 AM


All times are GMT -6. The time now is 09:02 PM.