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 tkaboris, Today, 05:13 PM
    0 responses
    2 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,281 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Working...
    X