Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceEntry

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

    BarsSinceEntry

    Hi support (or anyone)

    I was looking at the SampleMACrossOver strategy and trying
    to modify it.

    There are 2 moving averages as you know. I am using
    Renko bars, though I'm not sure if this is important to the code
    or not.

    CalculateOnBarClose = false;

    SetStopLoss(CalculationMode.Ticks,12);

    etc. etc.
    *************************************************

    If the stoploss is hit the trade is exited with a loss, but the Renko
    bar may still be an up bar let's say. That is, even if the CalculateOnBarClose
    is false, the bar the trade exited on may still be the last bar on the chart.
    An up bar.

    Let's say the moving average crossover is also in positive territory.


    So, does the software automatically wait until the next Renko bar
    to generate a long trade, assuming it is an up bar as well,
    or does it do so while the current bar is still in effect?
    (That would not be good.)


    Is BarsSinceEntry necessary code here?

    #2
    Stephen, with CalculateOnBarClose set to false the strategy is updated on tick by tick basis, this also means you can encounter whipsaws in your trade execution as entry triggers become true / false multiple times intrabar. BarsSinceEntry wouldn't be of much help, as it would not limit entries intrabar.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Stephen, with CalculateOnBarClose set to false the strategy is updated on tick by tick basis, this also means you can encounter whipsaws in your trade execution as entry triggers become true / false multiple times intrabar. BarsSinceEntry wouldn't be of much help, as it would not limit entries intrabar.
      Everything below this refers to Renko bars only.

      Ok, let's just assume CalculateOnBarClose=true

      If a strategy enters a long trade on an up bar and the stoploss
      is triggered within that same up bar...then using CalculateOnBarClose=true prevents
      a new long trade within that same up bar. Correct? (I hope)

      A new up bar would be the soonest a second long trade would be made, correct?

      I wasn't sure if Renko bars were different from candles, etc. because as I looked
      at a graph, a Renko bar instantly forms. The closing price doesn't change on the graph
      even using single tick Renkos. So you're saying that a moving average crossover
      strategy works tick by tick but a graph using the same moving averages as the strategy
      won't? Correct? Strategy in question uses: 1 SMA short term, 2 SMA long term
      In other words, long trade entered at a higher close, short trade entered at a lower.

      Hope I explained myself in the above.

      Thanks for any reply this week.

      Comment


        #4
        Stephen, my reply was related to all supported bartypes in NinjaTrader, I'm not too familiar with the custom Renko one you use - best would be to check this in realtime using your strategy and the Sim101 account with both settings for CalculateOnBarClose.

        The general thought behind this is - you would need to check if your strategy conditions can become true / false intrabar, if yes, you would need to live with the whipsaws potentially created by this or add filters to prevent the false triggers.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 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
        571 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