Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script Issues

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

    Script Issues

    I have a script that is supposed to only buy prior to a certain time in the morning. For some reason it doesn't work. Is there a time setting somewhere on NT that I have to adjust and align as well as for the Interactive Broker platform?

    #2
    cdnPATRIOT, NT would always use your local set PC time / zone as reference. Which NT7 and TWS version are you exactly working with here? Which time filter condition is used in the script? If you debug it, by for example changing bar colors when it would evaluate to true, does the outcome align with your expectations?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I'm working with TWS 938.1e and NT 7.0.100.14.

      Not sure what time filter condition is used in the script but here is the script.
      Attached Files

      Comment


        #4
        Originally posted by cdnPATRIOT View Post
        I'm working with TWS 938.1e and NT 7.0.100.14.

        Not sure what time filter condition is used in the script but here is the script.
        It looks like 11:00 am for a long, and 10:00am for a short are the cut off times by default.


        Code:
        		private int iTradeByTimeLong = 1100;        				        
         && Time[0].Hour * 100 + Time[0].Minute <= this.iTradeByTimeLong
        
        		private int iTradeByTimeShort = 1000;  
        && Time[0].Hour * 100 + Time[0].Minute <= this.iTradeByTimeShort

        Comment


          #5
          cdnPATRIOT, thanks. The timeFilter looks ok to me. However you would need to keep in mind ExitOnClose is generally false, so perhaps there's a situation where other day exits do not trigger as expected and thus the script holds overnight and exits outside the time filter when you don't expext? As the time filter would only apply to the entries.

          R14 or higher for TWS 938 should be fine, we generally would recommend to be on latest NT though, which currently is R22.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thanks Bertrand and Sledge. The cut off time should be 11 am for longs and 10 am for short. But it's adjustable in the strategy settings screen that I right click on after I open a chart.

            Exit on close should trigger when a certain defined volume level has not been reached. For some reason this hasn't worked as intended either.

            Back to this case though both buys occurred at about 12:20 pm well after the cutoff so it may be where there was a short trade from another day still in the system and the system covered the short. Otherwise no buys should occur what so ever after 11 am.

            Thanks for verifying that the time filter only applies to entries.

            I'm going to upgrade it to the next version of NT as well.

            Comment


              #7
              Hello cdnPATRIOT,

              Are you changing the iTradeByTimeLong or iTradeByTimeShort inside of the Parameters section of your Strategy?

              Also, are you checking the time that the strategy has entered inside of the NinjaTrader chart or you looking at something else like the TWS screen?
              JCNinjaTrader Customer Service

              Comment


                #8
                Hi JC
                "Are you changing the iTradeByTimeLong or iTradeByTimeShort inside of the Parameters section of your Strategy?"
                I'm leaving it as 11 pm for long and 10 am to go short. However, yesterday it happened again. The volume indicator and technical indicators were met at about 9:55 am but it went short at 12:34 pm.

                "Also, are you checking the time that the strategy has entered inside of the NinjaTrader chart or you looking at something else like the TWS screen? "
                Yes I'm looking at both the chart and the TWS screen. Still stuck on this one.
                I've made sure that I have the most up to date copy of NT.

                Comment


                  #9
                  Hello cdnPATRIOT,

                  1100 military time will be 11:00 AM, but I believe that to be a typo when it was 11 pm.

                  What order(s) are being filled that is making your strategy go short? You may add the TraceOrders = true inside of Initialize() to help see this.
                  JCNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by PaulMohn, Today, 05:00 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post PaulMohn  
                  Started by ZenCortexAuCost, Today, 04:24 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post ZenCortexAuCost  
                  Started by ZenCortexAuCost, Today, 04:22 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post ZenCortexAuCost  
                  Started by SantoshXX, Today, 03:09 AM
                  0 responses
                  16 views
                  0 likes
                  Last Post SantoshXX  
                  Started by DanielTynera, Today, 01:14 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post DanielTynera  
                  Working...
                  X