Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historic flag incorrect

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

    #16
    Originally posted by koganam View Post
    Then I am really flumoxed. Hm. I was reasonably certain that Historical would be false for every tick of the developing bar, and should show so if COBC = false.

    I guess I shall have to do a little experiementation later.
    Koganam always delivers - thanks for helping out. Since you're willing to take one for the team (i.e. spend time testing) let me throw you a bone. Compare those two and their respective outputs under different circumstances:

    Code:
    startIndex = Historical ? 0 : 1;
    Print("Historical INDEX: " + startIndex);
    startIndex = (Times[1][0] >= Times[0][0]) ? 0 : 1; 
    Print("Time based INDEX: " + startIndex);
    I'm actually currently using the times based one and it seems to be more reliable in live mode. Need to do more testing however....

    Comment


      #17
      Molecool

      Is this what you are stumbling upon?





      Originally posted by molecool View Post
      Exactly correct - yes.



      Yes, my strategy is rather complex and is based on 60-min candletick patterns. But I'm taking entries on the series 1 (i.e. 1-ticks) and that portion of the code needs to know which candle to evaluate. In historic mode it's actually 0 and it works fine because for instance at 18:33 (on the 1 series) the 19:00 candle does not exist yet. So I'm looking for instance at High[0] for a breach. However in live mode High[0] is the current 60-min candle as it's already active - thus my logic needs to look at High[1] for a breach to paint an entry.

      I hope this makes sense - all of this seems to work fine except that the historic flag is not working the way I expect it to. All I need to know is whether or not my logic is currently parsing in historic or live mode on the zero series. If there is an open/active candle I need to get a 1 value and not a 0.

      I may want to add that I attempted to set the index like this:

      Code:
      if (BarsInProgress == 1) {
        startIndex = Historical ? 0 : 1;
        ...
      }
      However it doesn't make a difference. I always get a 0 during live trading. It's driving me bonkers

      Comment


        #18
        Originally posted by molecool View Post
        Koganam always delivers - thanks for helping out. Since you're willing to take one for the team (i.e. spend time testing) let me throw you a bone. Compare those two and their respective outputs under different circumstances:

        Code:
        startIndex = Historical ? 0 : 1;
        Print("Historical INDEX: " + startIndex);
        startIndex = (Times[1][0] >= Times[0][0]) ? 0 : 1; 
        Print("Time based INDEX: " + startIndex);
        I'm actually currently using the times based one and it seems to be more reliable in live mode. Need to do more testing however....
        1. Do you have a BarsRequired check for all barSeries?
        2. Try reducing the BarsRequired to the absolute minimum. If zero is usable, then use 0, otherwise whatever value you can use so that any lookback does not fail.

        Comment


          #19
          Originally posted by koganam View Post
          1. Do you have a BarsRequired check for all barSeries?
          2. Try reducing the BarsRequired to the absolute minimum. If zero is usable, then use 0, otherwise whatever value you can use so that any lookback does not fail.
          I've set it to 0 (see below) - same difference - still getting intermittent behavior.

          Comment


            #20
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello molecool,

            With CalculateOnBarClose false, the first live tick on bars in progress 0 should flip your bool.

            I have attached the .cs file I am using to test this. Please open the output window and then start this script with the default parameters.

            Let me know if this is not printing the information you are after.
            I'm currently running your test strategy in live tape on the EUR/USD 60-min and this is what I'm getting:

            6/3/2013 8:54:05 AM: Start index: 0
            6/3/2013 8:54:05 AM: Start index: 0
            6/3/2013 8:54:05 AM: Start index: 0
            6/3/2013 8:54:05 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:07 AM: Start index: 0
            6/3/2013 8:54:08 AM: Start index: 0
            6/3/2013 8:54:10 AM: Start index: 0

            I attempted to reload the chart a few times but it doesn't change anything.

            Comment


              #21
              Originally posted by sledge View Post
              Molecool

              Is this what you are stumbling upon?


              http://www.ninjatrader.com/support/f...ad.php?t=46315
              Yeah, I had actually seen that - but thanks. I have BarsRequired set to 0 and COBC also set to false. Go figure...

              Comment


                #22
                Hello molecool,

                Thanks for testing my script.

                As long as you are using the default parameters for this script here is what should be happening.

                The script will print "6/4/2013 8:57:34 AM: Start index: 0" for each historical tick of data.

                Upon the first live tick of data this will switch to "6/4/2013 8:57:40 AM: Start index: 1". As well the word False should print as well.

                I think the issue may be that you have not scrolled to the bottom of the output window.

                Please do this with the Page Down key and not the mouse (on each print to the output window the window location is reset to the location of the cursor. If you have the cursor near the top of the window and you scroll down, the window will snap back up to where the cursor is. You can remove the cursor from the window by right-clicking the output window and selecting Clear. As long as you do not click in the window, it will scroll automatically with the latest prints hitting the window.)


                I did want to be sure this is working correctly and I have tested this.

                Below is a video of my test.
                http://screencast.com/t/64KosxQHrCSa

                Please let me know if you are not able to test this script correctly and I will set up a remote support session with you.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  Intermittent

                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello molecool,

                  Thanks for testing my script.

                  As long as you are using the default parameters for this script here is what should be happening.

                  The script will print "6/4/2013 8:57:34 AM: Start index: 0" for each historical tick of data.

                  Upon the first live tick of data this will switch to "6/4/2013 8:57:40 AM: Start index: 1". As well the word False should print as well.

                  I think the issue may be that you have not scrolled to the bottom of the output window.

                  Please do this with the Page Down key and not the mouse (on each print to the output window the window location is reset to the location of the cursor. If you have the cursor near the top of the window and you scroll down, the window will snap back up to where the cursor is. You can remove the cursor from the window by right-clicking the output window and selecting Clear. As long as you do not click in the window, it will scroll automatically with the latest prints hitting the window.)


                  I did want to be sure this is working correctly and I have tested this.

                  Below is a video of my test.
                  http://screencast.com/t/64KosxQHrCSa

                  Please let me know if you are not able to test this script correctly and I will set up a remote support session with you.
                  Thanks for the update and apologies for the delayed response, I just saw it. The problem I'm facing is intermittent behavior. As a matter of fact I do have the IDENTICAL code in my strategy and sometimes it works and plots a 1 in live mode but often (and intermittently) it starts plotting a 0 and I don't know why. FYI - your strategy appears to always work fine but I have not tested it for extended amount of times.

                  What I did do was to put a return statement right after I'm plotting the historic/live flag, basically ignoring the rest of my OnBarUpdate() method - thus it's basically just doing what your does. On reload it was doing it correctly. that is putting out 1s. Then I removed the return statement and reloaded and it was plotting 0s in live mode again. And yes, I always clear the window to make sure I look at the latest trace. On relaunch of NinjaTrader it then starts to plot 1s again - it's completely intermittent.

                  I don't think this behavior can be replicated with a simple test as apparently the complexity of my real strategy appears to affecting this flag. Perhaps it's due to some time based lag? BTW, as I said before - I have this in my init method:

                  Code:
                  this.CalculateOnBarClose = false;
                  this.BarsRequired = 0;
                  Here's a video file showing you what's happening. Sorry for the bad sound but I think it demonstrates my problem nicely. I'm also showing you what exactly I'm doing:



                  This is a very difficult problem for me to deal with as the problem is intermittent and I have no clue as to what may cause it. Your help would be most appreciated as I have literally spent weeks battling with this at this point.
                  Last edited by molecool; 06-06-2013, 02:09 PM.

                  Comment


                    #24
                    Hello molecool,

                    Thank you for the reply and for the video.

                    From the video, it seems as if the issue is the historical 0s that print before the live data.

                    The code you have will print 0s for the historical and start printing 1s for the live. This means every time you restart the strategy it will go through the historical data first which will print 0s, then it will get to the live data and start printing 1s.

                    If you do not want 0s to print, wrap the Print statement in an if historical check.

                    For example:

                    if (Historical == false)
                    {
                    Print(Time based INDEX: " + startIndexSeriesZero);
                    }

                    This will prevent the historical data from printing that line.

                    Unless you put if (Historical) return; at the beginning of OnBarUpdate the historical data is always going to process before the live data.

                    In your video, once 1 starts to print (and the data is live) I do not see any 0s printed after this point until you restart the strategy.

                    This means it is working correctly.


                    Please clarify what the issue is you are experiencing.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello molecool,

                      Thank you for the reply and for the video.

                      From the video, it seems as if the issue is the historical 0s that print before the live data.

                      The code you have will print 0s for the historical and start printing 1s for the live. This means every time you restart the strategy it will go through the historical data first which will print 0s, then it will get to the live data and start printing 1s.

                      If you do not want 0s to print, wrap the Print statement in an if historical check.

                      For example:

                      if (Historical == false)
                      {
                      Print(Time based INDEX: " + startIndexSeriesZero);
                      }

                      This will prevent the historical data from printing that line.

                      Unless you put if (Historical) return; at the beginning of OnBarUpdate the historical data is always going to process before the live data.

                      In your video, once 1 starts to print (and the data is live) I do not see any 0s printed after this point until you restart the strategy.

                      This means it is working correctly.


                      Please clarify what the issue is you are experiencing.
                      I know this is what you may be thinking but this was actually the live output. If you carefully watch the video in the beginning you'll see that it was updating and that the time stamps in my output were changing. It's a real issue that's of course difficult to perfectly record as it's intermittent.
                      Last edited by molecool; 06-06-2013, 03:29 PM.

                      Comment


                        #26
                        Hello molecool,

                        Thanks for the reply.

                        I have taken another look at the video, and I see that right at the start of the video the strategy is processing live data but still printing a 0. After reloading the strategy it begins to print 1s.

                        After the reload the last 0 that was printed that I can see, is printed at 3:55. This is also the time of the last historical bar on your chart.

                        The first 1 that is printed happens at 3:56:11 (the other go by too fast for me to see), however, this would confirm that the live data started after 3:55.

                        So after the reload this was correct.

                        When this happens and it is printing 0s in live data, please go to the Strategies tab of the Control Center. Is the strategy name yellow in that it is waiting to be flat?

                        When using the Historical property in a strategy that is running with "Wait until flat before executing live", the property will return "true" until the strategy reaches a flat state and switches to live executions.

                        http://www.ninjatrader.com/support/h...historical.htm
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello molecool,

                          Thanks for the reply.

                          I have taken another look at the video, and I see that right at the start of the video the strategy is processing live data but still printing a 0. After reloading the strategy it begins to print 1s.

                          After the reload the last 0 that was printed that I can see, is printed at 3:55. This is also the time of the last historical bar on your chart.

                          The first 1 that is printed happens at 3:56:11 (the other go by too fast for me to see), however, this would confirm that the live data started after 3:55.

                          So after the reload this was correct.

                          When this happens and it is printing 0s in live data, please go to the Strategies tab of the Control Center. Is the strategy name yellow in that it is waiting to be flat?

                          When using the Historical property in a strategy that is running with "Wait until flat before executing live", the property will return "true" until the strategy reaches a flat state and switches to live executions.

                          http://www.ninjatrader.com/support/h...historical.htm
                          Well, I'm unfamiliar with 'wait until flat' and will be investigating this further tomorrow morning (it's late over here in Europe). Could you please provide a bit more detail about this? I'm not sure I understand what exactly this means. Where do I set this property?

                          But if I understand you correctly then we may be on to something. Not sure if you noticed but I am actually drawing a text on the bottom right of the video with the current state (i.e. flat, short, or long, and some other info). At the beginning of the video, when the problem occurs in live mode, the strategy was already in a short trade when I pulled up that particular symbol. When I flipped to the next one it was running flat and - lo and behold - it was plotting the live (i.e. 1) flag in the output window.

                          In any case, thanks for the input - this is VERY helpful. If you could provide me with a bit more info on how to handle this and where to set this property I'd appreciate it. I suspect this has to do with wanting the strategy to go flat before taking on new trades or not. Implicitly I suspect that this affects the historical flag.
                          Last edited by molecool; 06-06-2013, 04:03 PM.

                          Comment


                            #28
                            Hi molecool,

                            This option is located in the Options window.
                            • Tools -> Options -> Strategies tab -> NinjaScript


                            The option Immediately submit working historical orders may prevent this.

                            Below is a link to the help guide where you can read about this option. Please refer to the section 'Understanding the NinjaScript tab'.
                            http://www.ninjatrader.com/support/h...tegies_tab.htm


                            Please let me know if I can be of further assistance.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #29
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hi molecool,

                              This option is located in the Options window.
                              • Tools -> Options -> Strategies tab -> NinjaScript


                              The option Immediately submit working historical orders may prevent this.

                              Below is a link to the help guide where you can read about this option. Please refer to the section 'Understanding the NinjaScript tab'.
                              http://www.ninjatrader.com/support/h...tegies_tab.htm


                              Please let me know if I can be of further assistance.
                              Alright, this seems to have caused the issue. After changing to 'submit live working historical orders' it's behaving as expected. Of course this is not a trivial issue and I will have to sort out how to handle 'missed' orders. Perhaps leaving the flag unchanged and waiting until the strategy goes flat would be preferable.

                              Thanks for shedding light on this.

                              Comment

                              Latest Posts

                              Collapse

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