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

Rolling time-based window

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

    Rolling time-based window

    Hello,

    This is my first post in here, so please be gentle. I'm new to NT and come to it from a Python coding background.

    I've got a fairly simple requirement (I think) but am stumped by my current lack of C# experience; am sure some of you more experienced guys and gals will have no problem pointing me in the right direction.

    I'm using OnMarketData() so that I can capture each update of the level 1 data as it is streamed live. I would like to capture a rolling X minute window of these bid and ask updates, and then perform some calculations on this window of data.

    In Python I would construct a timestamp-indexed pandas dataframe for this job. I'd then contribute the incoming bid and ask updates to this dataframe. I could then timeslice the dataframe using something like:

    [ (timestampOfLastTick - X minutes) : timestampOfLastTick]

    to get my X-minute window and then perform the calculations I need before the next tick update comes in from OnMarketData()

    What is the equivalent and correct way to approach this in NT and C# ?

    Thanks in advance for your thoughts.

    AhabMD

    #2
    Hello,

    Thank you for your post and welcome to our forums!

    This topic goes a bit out of the realm of what we can support as it is more of general C# inquiry therefore we wouldn't have any reference samples off hand (perhaps someone will post a working example of something you can reference)

    If you just need to make a time comparison, you can use a TimeSpan:



    If you actually need a way to store and loop through an array which contains that information, you'd need to create some sort of custom list or dictionary and store all of those values in some sort of struct, class or array (depending on your requirements). I'm including some 3rd party links which may help you here:

    Test structs. Understand that structs are value types and types like int are structs.

    Create a new List, add elements to it, and loop over its elements with for and foreach.
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    4 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    28 views
    0 likes
    Last Post wzgy0920  
    Working...
    X