Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Load historical ticks in array

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

    Load historical ticks in array

    Hi! Is it possible to load historical ticks into array (for certain period of time)? I want to compare their "bids" and "times" by loop. Thanks in advance for answer!

    #2
    Hello,

    Yes this would be possible.

    For this I don't think I would recommend an array because you have more than 1 value to compare. Instead I would recommend a List so that you can combine multiple items into rows to loop through.

    Here is more documentation on Lists:http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx

    This is a simple example of how you can create a list and add values and access the values.

    This adds the current bars values to the List and then once the CurrentBar is equal to the Count - 2 I allow it to loop through the list. You could change that to if(!Historical) if you want it to only process when realtime data comes in.

    Code:
    using System.Collections.Generic;
    
    private List<ListDefinition> newList = new List<ListDefinition>();
            public class ListDefinition
            {
                public double ClosePrice { get; set; }
                public double OpenPrice { get; set; }
                public double HighPrice { get; set; }
                public double LowPrice { get; set; }
            }
    
            protected override void OnBarUpdate()
            {
                newList.Add(new ListDefinition()
                {
                    ClosePrice = Close[0],
                    OpenPrice = Open[0],
                    HighPrice = High[0],
                    LowPrice = Low[0]
                });
    
                if (CurrentBar == Count - 2)
                {
                    foreach (ListDefinition item in newList)
                    {
                        Print(item.ClosePrice);
                    }
                }
             }
    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,290 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    9 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Started by Option Whisperer, Today, 09:55 AM
    0 responses
    8 views
    0 likes
    Last Post Option Whisperer  
    Started by halgo_boulder, 04-20-2024, 08:44 AM
    2 responses
    25 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X