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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          61 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X