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 08-04-2010, 05:19 PM   #1
jcash
Member
 
Join Date: Jun 2008
Location: Chicago
Posts: 32
Thanks: 0
Thanked 0 times in 0 posts
Default Multiple time frame issue

Please help me understand why this is happening.

simple strategy is added to a 33 tick chart. i have an added time frame of 1 tick and a counter for each tick within BarsInProgress == 1. looks like this:

Code:
protected override void Initialize()
{
       Add(PeriodType.Tick, 1);
       CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
    if (BarsInProgress == 1)
    {tickctr++;}

    if (BarsInProgress == 0)
    {
           Print ("Tickctr:    "+tickctr);
           Print ("date:  "+ToDay(Time[0])+" time:  "+ToTime(Time[0]));
           Print ("---------------------");
     
           tickctr = 0;
    }
}
my assumption of the result was that every Print of tickctr would show 33. not even close to being true. some results are below:

Quote:
Tickctr: 41
date: 20100804 time: 90345
---------------------
Tickctr: 25
date: 20100804 time: 90350
---------------------
Tickctr: 0
date: 20100804 time: 90350
---------------------
Tickctr: 0
date: 20100804 time: 90350
---------------------
Tickctr: 97
date: 20100804 time: 90352
---------------------
Tickctr: 31
date: 20100804 time: 90353
---------------------
Tickctr: 42
date: 20100804 time: 90357
---------------------
Tickctr: 23
date: 20100804 time: 90400
---------------------
Tickctr: 43
date: 20100804 time: 90403
---------------------
is my use of / understanding of multiple time frames wrong?

thanks
jcash is offline  
Reply With Quote
Old 08-05-2010, 06:09 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,410
Thanks: 252
Thanked 976 times in 959 posts
Default

With your shown code you would only see prints when the primary series (BIP0) updates.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 08-05-2010, 08:35 AM   #3
jcash
Member
 
Join Date: Jun 2008
Location: Chicago
Posts: 32
Thanks: 0
Thanked 0 times in 0 posts
Default works in real time but not in strategy analyzer

the following code works in real time but not in strategy analyzer:
Code:
protected override void Initialize()
  {
            Add(PeriodType.Tick, 1);
            
            CalculateOnBarClose = true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 1)
            {
                tickctr++;
                Print ("Tickctr:        "+tickctr+" Time: "+ToTime(Time[0]));
            }
            
            else if (BarsInProgress == 0)
            {
                Print ("---------------------");
                Print ("Tickctr:    "+tickctr);
                Print ("date:  "+ToDay(Time[0])+" time:  "+ToTime(Time[0]));
                Print ("---------------------");
                
                tickctr = 0;
            }
                        
        }
the following results are from today the 5th:
Quote:
Tickctr: 1 Time: 92645
Tickctr: 2 Time: 92646
Tickctr: 3 Time: 92646
Tickctr: 4 Time: 92648
Tickctr: 5 Time: 92648
Tickctr: 6 Time: 92648
Tickctr: 7 Time: 92648
Tickctr: 8 Time: 92648
Tickctr: 9 Time: 92648
Tickctr: 10 Time: 92648
Tickctr: 11 Time: 92649
Tickctr: 12 Time: 92649
Tickctr: 13 Time: 92649
Tickctr: 14 Time: 92649
Tickctr: 15 Time: 92649
Tickctr: 16 Time: 92649
Tickctr: 17 Time: 92649
Tickctr: 18 Time: 92649
Tickctr: 19 Time: 92649
Tickctr: 20 Time: 92649
Tickctr: 21 Time: 92649
Tickctr: 22 Time: 92649
Tickctr: 23 Time: 92651
Tickctr: 24 Time: 92651
Tickctr: 25 Time: 92651
Tickctr: 26 Time: 92651
Tickctr: 27 Time: 92652
Tickctr: 28 Time: 92652
Tickctr: 29 Time: 92652
Tickctr: 30 Time: 92652
Tickctr: 31 Time: 92652
Tickctr: 32 Time: 92652
Tickctr: 33 Time: 92652
---------------------
Tickctr: 33
date: 20100805 time: 92659
---------------------
the following results are from the 4th using strategy analyzer:
Quote:
Tickctr: 1 Time: 143617
Tickctr: 2 Time: 143617
Tickctr: 3 Time: 143617
Tickctr: 4 Time: 143617
Tickctr: 5 Time: 143617
Tickctr: 6 Time: 143617
Tickctr: 7 Time: 143617
Tickctr: 8 Time: 143617
Tickctr: 9 Time: 143617
Tickctr: 10 Time: 143617
Tickctr: 11 Time: 143618
Tickctr: 12 Time: 143618
Tickctr: 13 Time: 143618
Tickctr: 14 Time: 143619
Tickctr: 15 Time: 143619
Tickctr: 16 Time: 143619
Tickctr: 17 Time: 143619
Tickctr: 18 Time: 143619
Tickctr: 19 Time: 143619
Tickctr: 20 Time: 143619
Tickctr: 21 Time: 143619
Tickctr: 22 Time: 143619
Tickctr: 23 Time: 143621
---------------------
Tickctr: 23
date: 20100804 time: 143624
---------------------
Tickctr: 1 Time: 143624
Tickctr: 2 Time: 143624
Tickctr: 3 Time: 143624
Tickctr: 4 Time: 143624
Tickctr: 5 Time: 143624
Tickctr: 6 Time: 143624
Tickctr: 7 Time: 143624
Tickctr: 8 Time: 143624
Tickctr: 9 Time: 143624
Tickctr: 10 Time: 143624
Tickctr: 11 Time: 143624
Tickctr: 12 Time: 143624
Tickctr: 13 Time: 143624
Tickctr: 14 Time: 143624
Tickctr: 15 Time: 143624
Tickctr: 16 Time: 143624
Tickctr: 17 Time: 143624
Tickctr: 18 Time: 143624
Tickctr: 19 Time: 143624
Tickctr: 20 Time: 143624
Tickctr: 21 Time: 143624
Tickctr: 22 Time: 143624
Tickctr: 23 Time: 143624
Tickctr: 24 Time: 143624
Tickctr: 25 Time: 143624
Tickctr: 26 Time: 143624
Tickctr: 27 Time: 143624
Tickctr: 28 Time: 143625
Tickctr: 29 Time: 143625
Tickctr: 30 Time: 143625
Tickctr: 31 Time: 143625
Tickctr: 32 Time: 143625
Tickctr: 33 Time: 143625
Tickctr: 34 Time: 143625
Tickctr: 35 Time: 143625
Tickctr: 36 Time: 143625
Tickctr: 37 Time: 143625
Tickctr: 38 Time: 143625
Tickctr: 39 Time: 143625
Tickctr: 40 Time: 143625
Tickctr: 41 Time: 143625
Tickctr: 42 Time: 143625
Tickctr: 43 Time: 143625
Tickctr: 44 Time: 143625
Tickctr: 45 Time: 143625
Tickctr: 46 Time: 143625
Tickctr: 47 Time: 143625
---------------------
Tickctr: 47
date: 20100804 time: 143626
---------------------
why is it different?
jcash is offline  
Reply With Quote
Old 08-05-2010, 09:28 AM   #4
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

Hello Jcash,

Is it possible here the sequence of ticks is not matching up? Meaning when you start evaluating your 1 tick series-- it's not necessarily the 1st tick in your 33 tick series. It could be the 2nd, third, 33rd etc.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 08-05-2010, 09:56 AM   #5
jcash
Member
 
Join Date: Jun 2008
Location: Chicago
Posts: 32
Thanks: 0
Thanked 0 times in 0 posts
Default

Ryan,

that could be the problem, but doesn't explain the results of 0 and 97 (2.9x 33 ticks) in my 1st post.

how would you ensure synchronization of the 1 tick addition on the 33 tick chart in strategy analyzer?
jcash is offline  
Reply With Quote
Old 08-05-2010, 11:21 AM   #6
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

Maybe you could create a data series from this and sync according to this reference sample:
http://www.ninjatrader.com/support/f...ead.php?t=3572

It creates the series on the first OnBarUpdate and then value is set during BIP = 1.
NinjaTrader_RyanM 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
Strategy that includes multiple display panels and multiple time frame data burrmann Strategy Development 1 08-03-2010 04:53 AM
Multiple time frame issue _db8r_ Strategy Development 3 03-17-2010 08:12 AM
Multi-Time Frame code issue. strategy1 General Programming 32 01-14-2009 12:17 PM
Multi Time Frame Stop Loss Issue yimbot Strategy Development 15 01-03-2009 05:23 PM
Multiple Time Frame access stepwise General Programming 1 03-31-2007 03:33 AM


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