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

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.

    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 GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,221 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              438 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              9 views
              0 likes
              Last Post FAQtrader  
              Working...
              X