• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with BarsInProgress

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

    Problem with BarsInProgress

    Gday

    I am not able to get the following strategy up and running even though it backtests perfectly well in the Strategy Analyzer. I suppose the way I am handling the BarsInProgress functionality leads to this behavior. Basically, when I launch the strategy in the Control Center it doesn't issue the trades it should. It looks like it is not able to calculate the dummy1 variable from the index data set, even though does it perfectly well when backtesting.

    Here's a simplified code sample. Would you pls let me know what am I doing wrong that prevents the strategy to function in real time as it functions in backtesting?

    Thanks


    *************************

    protected override void Initialize()
    {
    Add ("^DAX",PeriodType.Day,1);
    Add (PeriodType.Minute,5);
    Add (PeriodType.Minute,60);
    }

    protected override void OnBarUpdate()
    {


    if (BarsInProgress == 1)
    {
    ss = StdDev(100)[0];
    ff = StdDev(10)[0];
    dummy1 = 1+ff/ss;
    }

    H4= ((dummy1*(PriorDayOHLC().PriorClose[0]);


    if (BarsInProgress == 3 && CrossAbove(Close, H4, 1) )
    {
    EnterLong();
    }

    }
    *************************

    #2
    Hi zerosum666,

    What version are you using? (Help>About)
    What is the primary series you are submitting to?

    Are you getting any errors in the Log tab upon enabling the strategy?
    Can you try using Print() statements to see if you get the expected values for each of ss, ff, dummy1 and H4
    Print() - http://www.ninjatrader-support.com/H...ide.html?Print

    Then use Print() to see if you conditions for order executions are indeed being satisfied
    http://www.ninjatrader.com/support/f...ead.php?t=3418
    TimNinjaTrader Customer Service

    Comment


      #3
      Thanks Tim

      I have checked the Log and indeed there is something there that I missed. When Starting the strategy the following error message is logged: "Error setting property Account for strategy: Object reference not set to an instance of an object".

      Can you shed some light?

      ver 6.5....16
      the print in window output gives bogus numbers when running live. In backtest, the output window gives correct numbers.
      I am using 5min primary but there's no difference using other primary aggregation.

      Thanks
      Last edited by zerosum666; 07-22-2010, 10:28 AM.

      Comment


        #4
        Hi zerosum666,

        This is likely coming from another section of the code, where you try to access an object that does not have a definition in the specific context of the code.

        You can find the area of concern with try/catch blocks:
        http://www.ninjatrader.com/support/f...ead.php?t=9825
        TimNinjaTrader Customer Service

        Comment


          #5
          The problem comes from this part of the code and in particular from the dummy1 variable calculation. For instance, if I assign a random value to that variable i.e. 1, the strategy works perfectly well. Hence, the problem is caused by NT being unable to access the data in that container and make the necessary calculation in r/t. In addition, NT Strategy Analyzer works perfectly well and computes the values for any given day without any error.

          The rest of the code is completely flawless.

          I am inclined to say NT is not able to handle properly some data feeds. In this case, the data I am trying to access to compute the dummy1 variable comes from Yahoo. Might be that the problem?

          Thanks

          Comment


            #6
            Hi zerosum666,

            Perhaps. Have you tested to see if the indicator works on a chart "PriorDayOHLC()" for prior close?

            Have you tried printing each of those variables to see if you get the expected value, as mentioned in post #2
            TimNinjaTrader Customer Service

            Comment


              #7
              Yes I did. Everything works perfectly well in the Strategy Analyzer, with dummy1 returning values in the range of .1-.5, as expected. In r/t though dummy1 always prints 0, which means that NT cant access that data container (yahoo), for some reason.

              The rest of variables are OK.

              Can you suggest some work around for this?

              Thanks
              Last edited by zerosum666; 07-22-2010, 12:33 PM.

              Comment


                #8
                Hi zerosum666,

                I am trying to narrow down which of the variables is problematic. Please print the "ff" and "ss".

                Also, try moving "H4" to a BarsInProgress, (or temp. commenting it out) perhaps you are trying to access that when the values do not exist.
                TimNinjaTrader Customer Service

                Comment


                  #9
                  ff=0 and ss=0
                  The H4 doesnt work in any bar in progress.
                  If I assign variable dummy1 = 1 everything works perfectly well.

                  Like I said, I am not able to access yahoo container in r/t even though in backtesting works perfectly well.

                  I am considering this being a problem of how yahoo posts price updates to their data server. Maybe they handle it in a way it messes with NT in r/t. Cant see any other explanation.

                  Let me know if you devise a work around for this.

                  Thanks
                  Last edited by zerosum666; 07-22-2010, 12:55 PM.

                  Comment


                    #10
                    Hi zerosum666,

                    I see, since Yahoo is an EOD provider only, that may be expected. Have you tried this on a real time data feed?
                    TimNinjaTrader Customer Service

                    Comment


                      #11
                      I dont have access to r/t index data, only yahoo unfortunately.

                      I am pretty sure there is way way to overcome the problem of yahoo being EOD. After all I don't need r/t index data, as just want to access the Close data for the last 100 days in the index, with the first data point being yesterday's close.

                      Can you provide some assistance?

                      Thanks

                      Comment


                        #12
                        Hi zerosum666,

                        You can try a Standard Deviation of one bar ago instead of the current bar.
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          That was something tried a long time ago. Obviously it doesnt work.

                          Comment


                            #14
                            zerosum666

                            Unfortunately, I do not have a workaround.
                            TimNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by vivekniwas, Today, 11:31 AM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Heath  
                            Started by Austiner87, Yesterday, 04:59 PM
                            1 response
                            9 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by rlcheny, Today, 10:38 AM
                            1 response
                            7 views
                            0 likes
                            Last Post NinjaTrader_Tyler  
                            Started by JAtrades, Today, 05:38 AM
                            5 responses
                            26 views
                            0 likes
                            Last Post rlcheny
                            by rlcheny
                             
                            Started by RobotSyndicate, Today, 08:27 AM
                            1 response
                            13 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Working...
                            X