Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating using stock data from different timezones.

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

    Calculating using stock data from different timezones.

    Hi,


    I would like to backtest a strategy using instruments based in Australia and the UK.

    I have daily data for the Australian stock index and minute data for UK stock, and want to use the daily change, i.e. Closes[(0)][0] > Opens[(0)][0], in the Australian index to decide whether to buy a stock at the start of the UK session.

    Unfortunately when I try this, the values of the Closes[(0)][0] and Opens[(0)][0] are for the PREVIOUS day. So if it is Tuesday morning in the UK, we should already have the value for the Tuesday Close and Open for the Australian index. However, the values that NinjaTrader uses are for the day before, i.e. Monday.

    Could someone let me know what is the best way around this issue?


    Thanks

    ST10


    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        
        /// </summary>
        [Description("")]
        public class DLv1vDATATEST1 : Strategy
        {
            #region Variables
            // Wizard generated variables
            #endregion
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
    
                Add("GSK", PeriodType.Minute, 1);
    
    
                CalculateOnBarClose = true;
                ExitOnClose = true;
                
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                
    
                if (BarsInProgress == 1)
                {
    
    
                    if (Bars.FirstBarOfSession)
                    {
    
                        if (Position.MarketPosition == MarketPosition.Flat)
                        {
    
                            Print(Time[0] + " : " + Closes[0][0]  + " : " + Opens[0]);
                            
                            if (Closes[(0)][0] > Opens[(0)][0])
                            {
                                
                                EnterLong();
    
                            }
                            
                            
                            else if (Closes[(0)][0] < Opens[(0)][0])
                            {
    
                                EnterShort();
    
                            }
    
    
                        }
    
    
                    }
    
                }
            }
      
    
            #region Properties
    
            #endregion
    
        }
    }

    #2
    Hello systemtrader10,

    Thank you for your post.

    The Strategy is set to CaculateOnBarClose = true, which means the strategy will not calculate on the current day bar but only the previous bar (i.e. yesterday's bar). You would want to set CalculateOnBarClose to false.

    If you need to have the minute data as CalculateOnBarClose = true you can look into the use of FirstTickOfBar with CalculateOnBarClose = false. For an example of this please visit the following link: http://www.ninjatrader.com/support/f...ad.php?t=19387

    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X