Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

setting xx amount of time before entering the next trade

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

    setting xx amount of time before entering the next trade

    another noobie question for you guys..... how do I go about setting my strategy to wait x number of bars after one trade, before entering into another trade...

    logically, using "Bars since entry/exit" makes sense, but I end up with nothing done as i don't have a first trade in place

    #2
    Hello kelvinlau2,
    You can check for how many bars have lapsed since the first bar of the session. Please use the below code to do it

    if (Bars.BarsSinceSession > 3)
    {
    //do something
    }


    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      hi Joydeep,

      thanks for the reply. Unfortunately I'm still unclear as to how to set a time buffer between trades.

      Suppose my code looks like this:

      protected override void OnBarUpdate()
      {
      // Condition set 1 LONG
      if (BarsSinceEntry() > 15 && CrossAbove(RSI(Close, 14, 3), 60, 10)
      EnterLong(10000, "LONG1");
      }


      I imagine no trades are ever initiated in my backtest because there is no initial entry for the BarsSinceEntry (or Exit) to look back to. So how do I get the process started? I've tried adding an EnterLong(100) in front of Condition set 1 so as to initiate a trade to look back to, but backtest still giving me nothing

      Comment


        #4
        Hello,
        Yes, since you wont have any entry the BarsSinceEntry wont work.

        To filter your trade for a specific time you can refer to this sample code


        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Originally posted by kelvinlau2 View Post
          hi Joydeep,

          thanks for the reply. Unfortunately I'm still unclear as to how to set a time buffer between trades.

          Suppose my code looks like this:

          protected override void OnBarUpdate()
          {
          // Condition set 1 LONG
          if (BarsSinceEntry() > 15 && CrossAbove(RSI(Close, 14, 3), 60, 10)
          EnterLong(10000, "LONG1");
          }


          I imagine no trades are ever initiated in my backtest because there is no initial entry for the BarsSinceEntry (or Exit) to look back to. So how do I get the process started? I've tried adding an EnterLong(100) in front of Condition set 1 so as to initiate a trade to look back to, but backtest still giving me nothing
          You want to key off BarssinceExit(), not BarsSinceEntry().

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          646 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          367 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          570 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X