Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade problem

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

    Trade problem

    I ran my strategy in a SIM environment today and no trades were taken. I then backtested and included today and found it should have taken a trade. I then ran market replay for today and again no trade was taken. In the market relay I found the reason no trade was taken because SMA(Close[1],20)[0] was the same as Closes[1][0] as if there was only a single bar there to calculate the SMA against. That bars set is from: this.Add(PeriodType.Day,1);

    Back testing seems to load all the bars and be fine. How come market replay does not see this data? Surely this data must have been backfilled when the strategy was started this morning on SIM. I saw it download data when I launched the strategy.

    What is going on here?

    #2
    The count for Closes[1].Count is showing 5 bars during market replay instead of the 20 needed to calculate. Seems odd that the value from SMA(Clsoes[1],20)[0]==Closes[1][0] though.. Any idea why it doesn't have all the needed bars? The strategy is set to "require" 50 bars. So therefore it should have downloaded 50 bars worth of data this morning

    Comment


      #3
      frostengine, the min bars check has to be fullfilled for all series in the strategy, then it would start trading - do you have the required daily data available supplied by your datafeed? If not a workaround is to use foir example 1440 min bars for this task.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        I am using Esignal for the data feed... when back testing i can easily go back to 2007 on the Ym contract for daily data... So this should not be the problem

        Comment


          #5
          No, then the data in backtesting is there - as you create your chart connected to Market Replay how many days back are setting up the chart with? Does it allow the min bars to be satisfied for the daily as well?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            When I connected to market replay,I set the strategy to run and specified 25 bars as minimum bars. The strategy starts to trade, IE the on bar starts to fire. However when printing the count of the daily bars its only 5. I opened a daily chart while in market replay and it showed at least 50 daily bars showing on that chart... So the data should be there.

            Today I turned the strategy on to trade again. Specified 25 as the number of bars. Now that I have extra Print statements I was able to see the strategy live today thought there was only 4 daily bars in the Closes[1] array.

            I am accessing the data when BarsInProgrogress==0. So essentially the code looks like this:

            if(BarsInProgress!=0)
            return;

            Print("Count: "+Closes[1].Count);

            That Count being printed is where I am getting 4 bars today, and 5 yesterday in market replay.

            Thoughts? I am using NinjaTrader 7 Beta. I believe I am 1 beta release behind from being current. Tonight I will make sure on latest version. Any idea what this problem could be? Some setting I am missing?

            Comment


              #7
              Perhaps there's a misunderstanding here - the min bars required has no connection to how many bars for all series are loaded historically by NinjaTrader - this will be determined by the 'DaysToLoad' property as you create your chart.

              The Min bars required just signifies how many bars (for all series involved) the strategy is waiting until it starts processing logic, so please try for example with a DaysToLoad setting of 30 to ensure there's enough historical data loaded to process it as needed.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Ah I bet that is what I am missing. Somehow I did not see the days to load option. Perhaps because I am use to setting up the strategy in a backtest which does not have that feature. That would make sense. Thanks

                Comment


                  #9
                  Ok the problem is not resolved. In fact the problem is more confusing now. I changed the days to load to 25. Started the strategy just now. My Print statement shows only 18 bars available. I stopped the strategy. Set days to load to 30. Started the strategy again now it shows 22 bars on Closes[1][0].count. Now it should at least have enough bars to calculate: EMA(Closes[1],20)[0]

                  I then looked at the value the Print statement was showing for EMA(Closes[1],20)[0] and for Closes[1][0] and this is where I get really confused. Its showing 9971 for both. Looks like the daily close on the YM 9-10 contract was 15 days ago. Hasn't closed at that price since. So why is it showing that as the last value in Closes[1][0]? And why would EMA be coming out with the same value?

                  This is what the code looks like:

                  Init
                  this.Add(PeriodType.Day,1);

                  OnBarUpdate
                  if(this.BarsInProgress!=0)
                  return;
                  Print("Time: "+Time[0]+" New Bar: "+Close[0]+" Last Day: "+Closes[1][0]+" EMA: "+EMA(Closes[1],20)[0]+" Bars Count: "+Closes[1].Count);

                  And here is the result from that print:
                  Time: 6/24/2010 9:15:00 AM New Bar: 10150 Last Day: 9971 EMA: 9971 Bars Count: 22

                  If I try and Print Closes[1][1] I get an exception for insufficient bars. This all works perfectly fine when backtesting. What am I missing?

                  I am using NT Beat 17 against contract YM 9-10. Set as 30 days to load for the strategy.

                  Comment


                    #10
                    Actually that last close price its showing is: 5/25/2010 3:00:00 PM as I did a Times[1][0] and thats what I got.... I also tried this on other instruments such as regular stocks.. all with the same outcome

                    Comment


                      #11
                      I tried using 2 different connections. Esignal and IB.. same results on both so its not a data feed problem. Also on both I was able to view daily charts and intra day charts going back with no problems...

                      Comment


                        #12
                        I set days to load to 50. Now it shows the correct value for the last daily close.. Only shows 33 bars available however. At least the strategy can now run. Question remains what is going on?

                        Comment


                          #13
                          Originally posted by frostengine View Post
                          I set days to load to 50. Now it shows the correct value for the last daily close.. Only shows 33 bars available however. At least the strategy can now run. Question remains what is going on?
                          frostengine, what is your MinBarsRequired now for the strategy?
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            I have tried values ranging from 20 to 30.... Currently I have it as 29... Most of the tests presented today when days to load was 30, i was using 29 as min bars required.... When i upped the days to load to 50, I left min bars required at 29

                            Comment


                              #15
                              Are you able to duplicate this problem?

                              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
                              21 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