• 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

barsInProgress bug or confusion

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

    barsInProgress bug or confusion

    I'm having an issue with a multi timeframe strategy.

    In realtime trading I need to use this:
    Code:
    if (BarsInProgress==0 || BarsInProgress==1 || BarsInProgress ==2 || BarsInProgress == 3)
    
    && (BarsSinceExit(0,"LongLimit", 0) >= 15)  || BarsSinceExit(0,"LongLimit", 0) == -1 )
    If I don't include all 4 bars in progress, and order will get set when in barsinprogress 0, then immediately canceled when it hits bars in progress = 1, etc. I assume it loops through the barsinprogress array , so if I have 1,3,15, etc. bars, when it hits a 15 minute bar it'll loop through all 3.

    but in backtesting, the basinprogress doesn't seem to work right, as it seems to take orders in the other timeframes. It should wait 15 minutes after exiting but might hit barsinprogress 2, which is a 3 minute timeframe so I get orders on that timeframe as well, only in backtesting.

    Not sure I'm explaining this correctly, but this is the solution I've come up with to get proper backtesting results, as well has having the strategy run properly in realtime:

    Code:
    ((Historical &&    BarsInProgress==0) || (!Historical && (BarsInProgress==0 || BarsInProgress==1 || BarsInProgress ==2 || BarsInProgress == 3)) 
    
    && (BarsSinceExit(0,"LongLimit", 0) >= 15)  || BarsSinceExit(0,"LongLimit", 0) == -1 )
    Perhaps I'm confused a little on how to code a multi timeframe strategy, but what I want is to use a 1 minute chart to take all the orders and then use the other timeframes for decisions. It's working now but I'm not sure my way is the proper way.

    Please respond if this doesn't make sense.

    #2
    We'll look into and will come back to you later.
    DierkNinjaTrader Customer Service

    Comment


      #3
      Hi woodside,

      Have you checked out the new syntax available in NT6.5?
      EnterLong(int barsInProgressIndex, int quantity, string signalName)

      You can specify which barsInProgress you want the order to execute on. I believe this way you might not need to do the whole BarsInProgress == 0 || ==1 etc. stuff.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        tried the following for a barsinprogress = 0 and an order for 1 contract:



        EnterShortStopLimit(0,1,Low[Bars.LowestBar(entryBars)],Low[Bars.LowestBar(entryBars)],"ShortLimit");
        and
        I get the following error:

        No overload for method 'EnterShortStopLimit' takes '5' arguments

        do the "low" functions need to be sent a barsinprogress also?

        Comment


          #5
          No they don't, but your syntax should have 6 arguments.

          EnterShortStopLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName)
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thanks for you help but still not working. Using this:

            EnterShortStopLimit(0,1,1,Low[Bars.LowestBar(entryBars)],Low[Bars.LowestBar(entryBars)],"ShortLimit");
            The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.EnterShortStopL imit(int, bool, int, double, double, string)' has some invalid arguments

            Argument '2': cannot convert from 'int' to 'bool'
            A bool is either a 1 or a 0, with no quotes required?

            I'm sure it's simple error but I just can't see it. Any idea when there will be docs on all the new 6.5 functions?

            Comment


              #7
              No, a bool is either true or false. You type "true" or "false".
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by 7robert, Today, 08:11 AM
              3 responses
              47 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by madmen, Yesterday, 09:18 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by stoner, Today, 09:01 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Conall, Yesterday, 04:00 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by neoikon, Today, 08:43 AM
              2 responses
              14 views
              0 likes
              Last Post neoikon
              by neoikon
               
              Working...
              X