Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No trade executed

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

    No trade executed

    Hi

    I hope that someone can help me with this. I run a strategy on ZB, and it was turned on all last week including friday. There were no trades executed. I shut down NT over the weekend and started it on monday morning.

    When I strated my ZB strategy, I found that there should have been a (quite profitable) position opened on friday. I do not understand how this can be possible?

    The code structure of the entry is quite simple: A trigger value is stored in variable0, and (if some more conditions are true) it goes:
    if (open[0] >= variable0 && close[0] <= variable0) {EnterShort();}

    thats it!

    The trade should have been at 12.13 am (european time) but in the log there are no entries between 11.58 am and 15.03 pm.

    I'm connected to IB and have a second KineticRT backup connection which both were up.

    Hope for your help to debug (this was an expensive error)

    Marco

    #2
    Hello Marco,

    We cannot really debug code as it would limit our support but we can definitely try to help understand what is happening. Is this a Strategy that you created (with custom code or using the Strategy Wizard) or is this strategy that you received from a 3rd Party?

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Sorry I didn't mean that you should debug my code. I wrote it, so no 3rd party purchase.

      Comment


        #4
        Hello Marco,

        Thanks for clarifying that for me.

        1. Where/How are you setting Variable0, and Variable1?

        2. Are you checking the values of Variable0, Variable1, Open[0], and Close[0] inside your Strategy to make sure they are what you expect by using the Print() method?

        For strategies you may add TraceOrders = true to your Initialize() method and you can then view valuable output related to strategy submitted orders through Tools > Output window.

        It may also help to add drawing objects to your chart for signal and condition confirmation.

        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          1. I set variable0 in the primary timeframe (simplified code):

          Code:
          if (BarsInProgress == 0)
          {
          if (some conditions)
          { variable0 = some indicator value} 
          }
          
          if(BarsInProgress == 1)
          {
          if (some other code
          &&open[0] >= variable0 && close[0] <= variable0) 
          {
          EnterShort();
          }
          }
          2. Yes I used print statements to debug. Variable0 prints. I didn't check for open/close. When I strated my strategy on monday historical processing of the data showed the trade!!! live it didn't enter?

          I use draw objects in m strategy and visually all conditions were met the trade was valid.

          I didn't inicialize traceorders, but will try if it helps find somethig new.

          Comment


            #6
            Hello Marco,

            Thanks for that snippet.

            I would definitely add the TradeOrder = true and see if your orders are not expiring. By default orders are cancelled if they are not filled on the bar that they are submitted on. In Multiseries scripts, the autoexpiration will be triggered by the next OnBarUpdate() received for any series.

            The order will remain for more than one bar if the conditions remain true for the order, or you use the advanced overloads with liveUntilCancelled = true. This sample can help submit these orders:
            http://www.ninjatrader.com/support/f...ad.php?t=19169

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              Hello JC,

              Thank you for this indication. However, I think my issue is more related to discrepancies between fridays live trading and processing of loaded data on monday morning. The code was exactly the same yet there were different results (one traded one didn't). I found in the help guide that such discrepancies can be linked to: 1. Fills (I don't think so, cause ZB is liquid and no order submission in log file) 2.CalculateOnBarClose (is set to true, so there should be no pbl) 3. Differences in data.

              I remember having had an issue with wrong trades due to my pc clock generating differnt time stamps in live data, so no I always manually sync with ib's tws clock.

              Then it says there can be discrepancies due to internet connection slowdown or latency. And ultimately there is no way to be sure about how data provider packages his bars.

              So no w my question is, how do I counter these issues so that my backtesting is accurate. Are there any best practice recoms?

              Thanks

              Comment


                #8
                Hello Marco,

                There can always be some discrepancies for the exact reasons that you have stated. When you have your strategy running in real-time what period do you have it for example 1 Min, 5 Min, 150 Tick, etc...?

                I would be curious if in real-time that your order was placed but expired as well since the fill process can be different, do you have anything setup to tell if your condition was triggered?
                JCNinjaTrader Customer Service

                Comment


                  #9
                  Hi JC,

                  It's 1min timeframe

                  I think what happened was that live prices gapped so that my if open>variable &close < variable condition was not met. When I dl IBs historical data on monday this gap disappeared.

                  So far that is the only reasonable explanation I can come up with. But unfortunately I havent recorded fridays action for replay so it's just speculative.

                  I already have an idea how to rewrite the code, to enter even on gaps, but not entering multiple positions with a canTrade bool.

                  I'll let you know.

                  Marco

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by corman, Today, 02:02 PM
                  1 response
                  2 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by Uregon, Today, 12:12 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Kate  
                  Started by kerplunk1899, Today, 10:03 AM
                  1 response
                  16 views
                  0 likes
                  Last Post NinjaTrader_Kate  
                  Started by rexsole, Today, 10:20 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_RyanS  
                  Started by pjsmith, Today, 03:01 AM
                  6 responses
                  17 views
                  0 likes
                  Last Post bltdavid  
                  Working...
                  X