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

if (BarsInProgress == 0)

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

    if (BarsInProgress == 0)

    Hi,
    How/Where do I implement the BarsInProgress overload on the following? Both are intended to look at the primary bar size.

    if (BSE == 1)
    {
    ExitLong(); ExitShort();
    }

    else if (BarsSinceEntryExecution() == BSE - 1)
    {
    ExitLong(); ExitShort();
    }​

    #2
    Hello trader3000a,

    Thank you for your post.

    I suggest reviewing the BarsInProgress page of the help guide, which includes a snippet that isolates logic depending on if the primary series is calling OnBarUpdate() or if an added series is calling OnBarUpdate();We have an overview of Multi-Time Frame & Instruments here:Additionally, the different help guide pages for order methods from the managed approach typically include an overload that allows you to specify int barsInProgressIndex. This is considered Advanced Order Handling and is detailed in the "Working with a Multi-Instrument Strategy" on the following page:Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hi,
      I've looked at the documentation and tried a few things, including:

      if (BSE == 1)
      {
      ExitLong(); ExitShort();
      }

      else if (BarsInProgress == 0)
      {
      if (BarsSinceEntryExecution() == BSE - 1)
      {
      ExitLong(); ExitShort();
      }
      }

      but i still get the error:
      Strategy 'openPEET': Error on calling 'OnBarUpdate' method on bar 20: Strategy 'openPEET/-1': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntryExecution() method in the context of a multi-time frame and instrument strategy.​

      Comment


        #4
        Hello trader3000a,

        Thank you for your reply.

        You are calling BarsSinceEntryExecution() though you will need to call BarsSinceEntryExecution(int barsInProgressIndex, string signalName, int entryExecutionsAgo) because you have a multi-series strategy. The syntax is listed here:You may use '' for signalName if you do not wish to specify a signal name, and you may use 0 for the last entry execution on entryExecutionsAgo if needed.

        Thank you for your patience.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Hi Emily,
          Thanks. That did the trick
          David

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          5 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          12 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          13 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,982 views
          3 likes
          Last Post jhudas88  
          Working...
          X