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

Zen-Fire time data questions?

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

    #16
    Originally posted by NinjaTrader_Ray View Post
    Programming against OnMarketData() we consider advanced programming. I believe we even state that in the Help Guide. I can provide you some guidance but you are really on your own since the questions you ask are outside of NinjaScript and deal with basic programming.

    Also, why not just make sure your PC clock in in sync?
    Sync'ing the PC clock would be too easy

    Actually I sync it up right before the opening everyday, but when dealing with a certain indicator I use, I often get a different open price on my 1min chart compared to my 150tick chart, so I decided to look in to solving the issue with grabbing the correct open tick price. My strategy must have the correct open price on both charts.

    Here is what I worked out. It may not be the cleanest way to do it, but I wasn't in the mood to study the Microsoft site.

    private bool xChange = false; //exChange is about to open
    private bool needData = true; //Looking for the true opening price
    private double o = 0; //First tick - true opening price

    protected override void OnBarUpdate()
    {
    if (ToTime(Time[0]) >= 72950 && ToTime(Time[0]) <= 73010)
    {xChange = true;}
    else{xChange = false;}
    //More strategy code below here........
    }
    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (xChange)
    {
    if (e.MarketDataType == MarketDataType.Last)
    Print("Time = " + e.Time + " " + e.Price);
    if(needData)
    {
    if (i == 1)
    {
    o = e.Price;
    needData = false;
    }
    if (ToTime(e.Time) == 73000)
    {i = 1;}
    }
    }
    }

    insomniac

    Comment


      #17
      I am told that Zen-Fire provides tick timestamps to microsecond precision. When I use e.Time in OnMarketData, I only get timestamps to second precision. How can I make NinjaTrader not chop off the microseconds when it converts the original Zen-Fire tick timestamps to my local PC time?

      Comment


        #18
        honvl, unfortunately it's not supported to access the sub second timestamps programmatically.
        BertrandNinjaTrader Customer Service

        Comment


          #19
          When I use the C# Stopwatch class to time the difference between two OnMarketData events, it seems that the more indicators I have loaded, the greater the minimum difference becomes. This means that OnMarketData is only processed after other tick-based indicators are calculated. What programming methods can I use to assure that a certain indicator or processing loop is given the highest processing priority on an incoming tick?
          Last edited by honvl; 05-01-2009, 04:40 AM.

          Comment


            #20
            Hi honvl, unfortunately there's no method you can use for this.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            23 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            45 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            22 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            181 views
            0 likes
            Last Post jeronymite  
            Working...
            X