Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

My strategy dont place orders anymore

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

    My strategy dont place orders anymore

    Hello for some reason my strategy dont open orders anmore.

    Strategy 'TEST/265655860': An order placed at '18.01.2021 00:02:00' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met.

    This is the only message I saw.

    How can I reset the ninjatrader to one day before ?

    I can do manual orders but strategy dont open orders anymore when the condition is activated.

    #2
    Hello Uregon,

    Thanks for your post.

    This message indicates that the strategy tried to place an order before the BarsRequiredToTrade property was you set was met. By default, BarsRequiredToTrade is set to 20. This means 20 bars would need to be processed on the chart before trades are placed.

    To avoid this message, you could change the BarsRequiredToTrade property to 0 in the Strategies Properties when enabling the strategy.

    You could also set BarsRequiredToTrade in the State.SetDefault section of your script.

    Or, you could consider creating a condition at the top of the OnBarUpdate() method that compares CurrentBar to BarsRequiredToTrade. This code might look something like this.

    if (CurrentBar < BarsRequireToTrade)
    return;


    See the help guide pages below for more information.

    CurrentBar: https://ninjatrader.com/support/help...currentbar.htm
    BarsReqiredToTrade: https://ninjatrader.com/support/help...redtotrade.htm

    Let us know if we may assist you further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3

      As you can see in the picture, the chart showes me that orders are made but on the account nothing happen anymore NinjaTrader_BrandonH
      Attached Files

      Comment


        #4
        Hello Uregon,

        Thanks for your note.

        Are these orders historical (virtual) orders that appear when enabling the strategy?

        Or, are these realtime trades that are made after the strategy has been enabled?

        Does the strategy show as yellow or green in the Strategies tab of the Control Center?

        Note that when a strategy is enabled, it processes historical data to determine trades that the strategy would have made on the data that is already on the PC/chart and to determine what position the strategy is in. These calculated historical positions could be seen on the chart.(Strategy positions are separate from actual Account positions.)

        Please see the help guide pages below for more information about Start Behavior and Strategy Position vs Account Position.
        Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm
        Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          NinjaTrader_BrandonH

          Are these orders historical (virtual) orders that appear when enabling the strategy? Yes

          Does the strategy show as yellow or green in the Strategies tab of the Control Center? Its yellow

          Comment


            #6
            Look here, you know how I mean ?

            Comment


              #7
              Hello Uregon,

              Thanks for your note.

              When a strategy is yellow (or orange on some monitors) in the Strategies tab of the Control Center, this means that the strategy entered a historical (theoretical) position in the historical data that has been loaded.

              It also means that you have "Wait until flat" selected for the 'Start behavior' option in the strategy parameters.

              This means that once the strategy has finished processing the historical data and has transitioned to real-time, it will wait until there is a real-time order submission that will cause the strategy to become flat. This also includes changing from a long position to a short position or vice versa as the position would pass through flat.

              This also applies to secondary instruments if there are added series to the script. All positions must be flat before real-time orders will begin.

              You can change the start behavior to "Immediately submit" in the parameters of the strategy. Immediately Submit automatically submits working orders from when the strategy processed historical data, and assumes the strategy position and account position are where you want it when you enable the strategy. This is typically used to have a strategy resume a position after disabling/enabling. If the strategy already had live orders running, the orders will resume with the new enablement of the strategy if they match the historically calculated orders. If the orders calculated from historical data do not match the live working orders, the live working orders will be cancelled and replaced by those calculated from historical data.

              Sync Account Positions is an additional option that has NinjaTrader submit an order to sync the account position to the position calculated by the strategy. (Not the other way around.)

              If you do not want the strategy to calculate a position from processing historical data. Simple add if (State == State.Historical) return; to the top of your strategy logic so historical processing is skipped. The strategy will then always start from a flat position because it has not calculated any orders.

              See the help guide documentation below for more information.
              Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm
              Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

              Additional information could be found in this forum thread - https://ninjatrader.com/support/foru...ion#post811541

              Let us know if we may assist further
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                NinjaTrader_BrandonH

                "If you do not want the strategy to calculate a position from processing historical data. Simple add if (State == State.Historical) return; to the top of your strategy logic so historical processing is skipped. The strategy will then always start from a flat position because it has not calculated any orders."


                Yes please! So where Exactly have I to insert it? Can you show ?

                Comment


                  #9
                  Hello Uregon,

                  Thanks for your note.

                  You would add if (State == State.Historical) return; to the top of the OnBarUpdate() method in your script.

                  For example, see below.

                  Code:
                  protected override void OnBarUpdate()
                  {
                      if (State == State.Historical)
                          return;
                  
                      //rest of your logic here.
                  }
                  Let us know if we may assist further.
                  <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                  Comment


                    #10
                    NinjaTrader_BrandonH Please look at my picture. I insert it like this.

                    I activated the strategy to "wait until flat" mode again and the strategy is still yellow and create historical ghost orders in my nonlife account.


                    protected override void OnBarUpdate()
                    {
                    if (State == State.Historical)
                    return;

                    if (BarsInProgress != 0)
                    return;

                    if (CurrentBars[0] < 1)
                    return;

                    // Set 1
                    Attached Files

                    Comment


                      #11
                      Hello Uregon,

                      Thanks for your note.

                      Please send us an exported copy of the strategy in question so that we may test it on our end.

                      See this help guide page for information about how to export a NinjaScript Strategy: https://ninjatrader.com/support/help...tAsSourceFiles

                      I look forward to assisting further.
                      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Yesterday, 05:17 AM
                      0 responses
                      67 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      142 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      76 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      47 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      51 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X