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

Trade time problem (inconsistent in backtesting & live)

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

    Trade time problem (inconsistent in backtesting & live)

    Hi,

    I am trying to trade FDAX, and in session template, I choose "Euronext GMT Index futures RTH2"

    I have programmed this

    if (ToTime(Time[0]) < ToTime(4, 0, 0))
    return;

    I expected no trades will happen before 4am EST. It works so in my backtestings, no trade happens before 4am EST.

    However, when I run the strategy on live data, the trades triggered before 4am EST...

    why is that so?

    #2
    Which timeframe and bars type are you working on here ShadowKnows?

    For covering all FDAX / Eurex hours, I would suggest working with the default Eurex Equity Index session template.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Which timeframe and bars type are you working on here ShadowKnows?

      For covering all FDAX / Eurex hours, I would suggest working with the default Eurex Equity Index session template.
      3mins regular bar.

      Does using different session template affect the code?

      if (ToTime(Time[0]) < ToTime(4, 0, 0))
      return;

      Does the code mean 4am EST always or depend on the session template?

      But why does it work in backtesting (no trades before 4am EST) but not working on live data?

      Comment


        #4
        The times you check against are always your local PC time / timezone, that's what NT uses on the charts. I was just suggesting the full Eurex hours in case you were not aware, if you decided for another template to use for specific reasons then just disregard.

        Do all your entries come from the OnBarUpdate() method in which I suppose you use the time filter code? Do you see fresh entries outside of this time, or for example an exit?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          The times you check against are always your local PC time / timezone, that's what NT uses on the charts. I was just suggesting the full Eurex hours in case you were not aware, if you decided for another template to use for specific reasons then just disregard.

          Do all your entries come from the OnBarUpdate() method in which I suppose you use the time filter code? Do you see fresh entries outside of this time, or for example an exit?
          Sure, thanks for your suggestion for the session template, I will try it.

          As for the time problem, I will check if my local time is messed up and I will test around. Thanks.

          Comment


            #6
            Hi I think I have a similar problem. Have you solved yours?

            Thanks

            Marco

            Comment


              #7
              Hello Marco,

              Thank you for your post.

              Can you provide the Instrument and Session Template you are using?
              Can you also provide the code used to filter the hours?
              Are you seeing trades in real-time at unexpected hours but backtesting is performing correctly?

              I look forward to your response.

              Comment


                #8
                Hi Patrick,

                I trade ZB (09-14) with the default session "CBOT Interest Rate ETH". The time filter logic is as follows:

                Code:
                StartTrade = 16;
                EndTrade = 22;
                if (ToTime(Time[0]) >= StartTrade*10000 && ToTime(Time[0]) <= EndTrade*10000)
                					{
                ... some entry condition
                }
                I see trades in backtests but no trades in live. I had a strategy running, it did not trade, is turned it off and on again, now I there was a historical trade.

                I had opened a thread here, but I'm still searching for a solution.

                Marco

                Comment


                  #9
                  Hello Marco,

                  Thank you for your response.

                  Do you see any errors in the Log tab when running the strategy on real-time data?
                  When enabling the strategy is it Yellow or Green?

                  Comment


                    #10
                    Hi Patrick,

                    The strategy is green when running. When i turn it on, the log only shows the enable message. I had used traceorders and print to see what is happening and for the trade that did not happen it reads: "Entered internal PlaceOrder() method". Don't know if that helps.

                    Thanks for your efforts,

                    Marco

                    Comment


                      #11
                      Hello Marco,

                      Thank you for your response.

                      Testing your condition on my end I cannot reproduce this item. Can you forward me a test script or the full strategy? Can you also provide the Period Type and Interval used for the ZB 09-14?

                      Comment


                        #12
                        Hi PatrickH

                        I attached a stripped down MWE of my code. I trade ZB 09-14 in 30 min period.

                        Thanks,

                        Marco
                        Attached Files

                        Comment


                          #13
                          Hello marcoheimann,

                          Thank you for your response.

                          I am not seeing any trades in real-time or backtesting. Can you provide the exact settings used for the strategy in real-time and backtesting?

                          Comment


                            #14
                            I attached a screenshot of the backtest settings. Data is from Kinetick.

                            Marco
                            Attached Files

                            Comment


                              #15
                              Marco,

                              I took a look at your script.

                              In the While loop, you have x = 0 and check the bar ago of BollingerBand with -1 index.

                              In realtime this is will return 0 and will always be true and stopping the loop, thus x++ is never called and the condition x < SpanneKlein will always be true and thus returning the method and not entering orders.

                              If you want to look a bar back you would need to use x+1 for the indexing.
                              Last edited by NinjaTrader_CalH; 07-24-2014, 12:00 PM.
                              Cal H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X