• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 heiken ashi tick bars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    NT8 heiken ashi tick bars

    i created the following simple strategy code to count ticks in a heiken ashi 1000 tick bar chart run through the strategy analyzer:

    Code:
    public class HAticktest : Strategy
        {
            private int tickcounter;
            
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Strategy here.";
                    Name                                        = "HAticktest";
                    Calculate                                    = Calculate.OnBarClose;
                    EntriesPerDirection                            = 1;
                    EntryHandling                                = EntryHandling.AllEntries;
                    MaximumBarsLookBack                            = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution                            = OrderFillResolution.Standard;
                    Slippage                                    = 0;
                    StartBehavior                                = StartBehavior.WaitUntilFlat;
                    TimeInForce                                    = TimeInForce.Day;
                    TraceOrders                                    = false;
                    RealtimeErrorHandling                        = RealtimeErrorHandling.StopCancelClose;
                    BarsRequiredToTrade                            = 20;
                    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration    = true;
                    
                    //inputs
                    
                    //variables
                    tickcounter                        = 0;
                    
                }
                else if (State == State.Configure)
                {
                    AddDataSeries(Data.BarsPeriodType.Tick, 1);
                }
                            
            }
    
            protected override void OnBarUpdate()
            {
                if (BarsInProgress == 0)
                {
                    Print(string.Format("{0};{1};{2};{3};{4}", Time[0], "X", tickcounter, "X", "X"));
                    tickcounter = 0;
                }
                
                if (BarsInProgress == 1)
                {
                    tickcounter++;        
                }
            }
    adds one to tickcounter every time BarsinProgress == 1 takes place , the secondary data series of 1 tick. prints to the output window every time BarsinProgress == 0 takes place, then reset to 0.

    my thought was that the tickcounter prints should be 1000 every time. not the case. see the attached screen.

    why the vast difference in tick counts?
    Attached Files

    #2
    Hello jcash, and thank you for your question.

    We have explained the reason why e.g. a 25 tick bar will not have 25 visible OnBarUpdate calls in this section of the NT8 help guide.

    Originally posted by http://ninjatrader.com/support/helpGuides/nt8/en-us/?multi-time_frame__instruments.htm#WorkingWithMultiTimeFr ameObjects
    Shared Timestamps
    In circumstances where multiple bars share the same exact timestamps, your primary bars series will always be processed first, followed by the secondary bars series (regardless of the period value used). Consequently, if you were looking to obtain a value from the secondary bars series, it would ONLY be available after the primary series has been processed for the same timestamps. For example, consider a news event or a fast moving market with an influx of ticks (session begin/session end). This activity will yield a wider range of bars than usual and the probability of those bars sharing the same timestamps increases. If such a succession of bars with the same timestamps is processed, the primary bars would be processed first and then the secondary bars during this period.
    Knowing the above, we can then imagine a scenario where you had 25 tick bars. Bars 22-27 share the exact same timestamp, since we only have milisecond granularity, and multiple price changes are often reported during the same milisecond. Bars 49-51 each close on distinct timestamps. Thus, you would not see 25 printed out in your code, you would instead see 27 on one bar close, and 23 printed on the subsequent one.
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by timcjpfx, Today, 06:22 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by welson, Today, 08:26 AM
    2 responses
    12 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by brucerobinson, Today, 08:27 AM
    3 responses
    10 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by Leeroy_Jenkins, Today, 07:45 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by 1001111, 02-22-2020, 09:10 AM
    5 responses
    41 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X