Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceEntry

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

    BarsSinceEntry

    I am using BarsSinceEntry within a strategy but when testing using market replay no trades are being fired.

    Syntax is :

    if(BarsSinceEntry("LongEntryCrosses")>1)
    {
    //enter long trade
    LongOrderCrosses = EnterLong(LotSize,"LongEntryCrosses");

    }

    Is there a reason for this?

    If I take out the test on some bars the strategy is attempting to place a trade multiple times (100s) and this is then being cancelled due to logic I think within the strategy

    #2
    mballagan,

    You cannot use that condition like that because for the very first trade there was no BarsSinceEntry() > 1. You will need to code a set for the first trade and a separate set for subsequent trades you wish to use the BarsSinceEntry logic with.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      BarsSinceEntry

      Ok thanks so I have used the following code:

      bool entertradecondition = false;


      Trade firstTrade = Performance.AllTrades[
      0];

      if(firstTrade == null)
      {
      entertradecondition =
      true;
      }
      else
      {
      entertradecondition = BarsSinceEntry()>
      1;
      }

      if(entertradecondition)
      {
      //enter trade

      }

      Comment


        #4
        mballagan,

        You can try it.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          BarsSinceEntry

          It doesnt seem to work. I have more than one time series in the strategy although only executing trades on the primary series.

          If using the syntax:

          Trade firstTrade = Performance.AllTrades[0];

          Is there a way I can retrieve the label the trade was initialised under?

          For example if EnterLong("LongOrder1") was used the label is LongOrder1.

          Comment


            #6


            You will want to go to the individual IExecutions and then grab the Name properties from them.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X