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

AddDataSeries Delay in Values Being Called

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

    AddDataSeries Delay in Values Being Called

    Hi,
    I've searched forum and guide for an answer and can't find it so I need to ask the experts.

    There is a time delay reading the Stoch values from an AddDataSeries chart.

    I have two charts open: Same market
    1. 15 Range chart. Strategy runs on this one and calls the Stochastics from a 5 minute chart. No indicators.
    2. 5 Minute chart. (the AddDataSeries chart) Stochastics indicator only.

    I have the Stoch K value (being called from the 5 min chart) print to the Output window (by the Strat on the 15 Range Chart).

    Start the Strat. At close of bar on the 15 range chart, it prints the K
    value. It does not match the K value on the 5 min chart. This continues for about 20 bars or so on the 5 min chart. Then, the K value being printed "catches up" with the K value on the 5 min chart and reads correctly the rest of the day.

    Its as if the AddDataSeries chart doesn't see any historical data and the Stoch starts at the close of the 1st 5 min bar once the strategy starts. Then catches up after enough bars have printed to match the open 5 min chart.

    Is there anything I can do so it reads the K value correctly from the very start? (some variable added to the AddDataSeries code ???)

    The strat trades based off the K value of the 5 min chart so I really need it working from the "get go". Or do I have to start the Strat an hour or two early so the K can catch up to the real 5 min chart?

    Thanks!




    #2
    Hello JoeF1953,

    Thank you for your reply.

    I'm seeing them differ in a test script when running them both On Bar Close. However, running the strategy and the Stochastics On Price Change shows them match immediately as the stoch values would update on both whenever the price changes. I noted that when I started the strategy the printed Stoch value from the strategy did match the Stoch value from a few bars prior to the current 5 minute bar - do you see the same?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Yeah, what Kate says.
      What is your Calculate setting?

      Do any of the bars on the 15-Range chart share the exact same timestamp
      as any of the bars on the 5-Minute chart?

      If so, you'll run into a delay, because the 15-Range OnBarUpdate is called
      first, before the 5-Minute OnBarUpdate is called.

      Have you studied this page? I mean really studied it? Open all the sections
      at the bottom, and follow their long sequential example very carefully.

      Comment


        #4
        Thanks to both of you for your quick reply!

        Kate, no, not really. I started the strat and immediately paused it on the first print of the k value. I scrolled back the 5 min chart 1 bar at a time and went back at least 20 bars and didn't see any k value on the 5 min that matched the first print. I don't think I can run this strat in On Price Change since thats basically the same as each Tick (I Think) since the price basically changes on each tick or so on the 15 Range. This strat must be run in On Bar Close. (It gets complicated since it starts setting entry levels on the 15 Range based on the first bar Close after the Stoc K crosses a threshold on the 5 min.)

        bltdavid, as just mentioned Calculate is set OnBarClose.
        I started the strat and paused after 2 bars. Neither match the timestamp on the 5 min of current bar or the last closed bar.

        I've been playing with it a while now and starting to suspect its a Replay issue. I have NOT run this in live Sim yet.

        If I close Ninja and restart, open Replay connection and start the strat, I get the discrepancy. If I let it play through a couple hours of data, stop the strat, then scroll back in time (without stopping Replay connection) and start the strat, it reads perfectly. ??? Its as if the strat now sees the historical replay data. I think I won't know for sure if there is actually a problem until I run it Live Sim. I have to let my strategy running on my live account finish (its on a VPS and I can only have one Live connection) and then I'll test this new one in Live Sim on my home PC.

        I'll let you know how it goes. I sure hope I haven't wasted your time!

        I'll go study the page you referenced. I'm sure I'll learn something...

        Comment


          #5
          I wrote a quick Stoch strat WITHOUT a DataSeries added and tested on Live Sim. The K value prints exactly what the Stoch K indicator is reading on the very first bar. I think the main issue is with Replay data.
          With that said, the Strat I'm having the delay with immediately disables itself when running on Live Sim. I checked the log and getting the dreaded Error 'OnBarUpdate' Index out of range AND Error 'OnStateChange' Index outside bounds of the Array. I removed the AddDataSeries and all references to the Stoch on that it ran with no more errors. All problems point to the AddDataSeries and me not knowing how to set the Array and Index it seems. I thoroughly read the page that bltDavid referenced and I think I understand what its explaining and what its doing, but without more detailed examples showing HOW to do it (the Code I need to get rid of the error) I'm lost. My programming skills are severely limited so I guess I'll just stick with not adding any DataSeries to reference. Oh Well..... Thanks to you BOTH anyway!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          10 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          56 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          8 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          47 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X