Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

most recent closed bar

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

  • NinjaTrader_CalH
    replied
    The last bar is referring the number of bars to look back which must be a minimum of 1 bar. This is because it needs to test when the data series was either greater than or less than that second data series and then the current bar is greater than or less than that second dataseries.

    We define a CrossAbvoe as --
    Code:
    if (dataseries1[1] < dataseries 2[1] && dataseries1[0] >= dataseries2[0])

    Leave a comment:


  • zachj
    replied
    Ok that's what I figured.

    In the guide for CrossAbove they say below that the last bar is 1 that's only if cobc is set to false right? If it was set to true the last bar would be the 0 bar? They don't specify. Just want to make sure I'm solid on this.

    // Go long if 10 EMA crosses above 20 EMA within the last bar
    if (CrossAbove(EMA(10), EMA(20), 1))
    EnterLong();

    Leave a comment:


  • NinjaTrader_CalH
    replied
    Zachj,

    With the Strategy Analzyer you would not be able to grab that most current bar like with the chart.
    However, using an intrabar granularity would be able to help simulate that COBC set to false. Link is below on a reference sample -
    http://www.ninjatrader.com/support/f...ead.php?t=6652

    Leave a comment:


  • zachj
    replied
    I'm backtesting though so it's always going to be cobc true

    Leave a comment:


  • NinjaTrader_CalH
    replied
    Zachj,

    You would have to switch to COBC false in order to get the current day's high for the scenario you described. If you need to run the rest of the code with COBC set to true, you can use a filter condition for first tick of bar to simulate this -

    Code:
    if(FirstTickOfBar)
    {
         //rest of the strategy goes here...
    }
    http://www.ninjatrader.com/support/h...ttickofbar.htm

    Leave a comment:


  • zachj
    replied
    Sorry one more. If I have cobc true how do I get the current high of the daily bar in progress? If my primary bar is a daily bar I can't say High[0] for cobc true because the daily candle hasn't closed yet.

    Leave a comment:


  • NinjaTrader_CalH
    replied
    SMA()[0] would give you the 9:35 bar in this case

    Leave a comment:


  • zachj
    replied
    Yes I meant to state COBC = true. Then my second part of the question is, with the SMA's for the most recent closed SMA value I would have to use 1 instead of 0 I believe?

    So again if it's 9:37am, 5min bars, cobc true, SMA()[1] would give the SMA value at 9:35? Or would I use SMA()[0]?

    Leave a comment:


  • NinjaTrader_CalH
    replied
    Hi Zachj,

    This will depend on the CalculateOnBarClose and what it's set to.

    If this is set to true, then yes the Close[0] would be the 9:35 bar while the bar being built would be the 9:40 bar.

    If this is set to false then the Close[0] will be the 9:40 bar.

    Leave a comment:


  • zachj
    started a topic most recent closed bar

    most recent closed bar

    As with swing where 0 is the most recent pivot, is Close[0] the same, basically it's the close of the most recent completed bar?

    So if it's 9:37am and I'm using 5min bars, would Close[0] give me the close price at 9:35am?

Latest Posts

Collapse

Topics Statistics Last Post
Started by Nebula94, 04-15-2025, 02:41 AM
2 responses
30 views
0 likes
Last Post Nebula94  
Started by Mindset, Today, 12:46 AM
0 responses
9 views
0 likes
Last Post Mindset
by Mindset
 
Started by moneymaster, Today, 12:38 AM
0 responses
5 views
0 likes
Last Post moneymaster  
Started by WilsonFoster, Yesterday, 11:35 PM
0 responses
12 views
0 likes
Last Post WilsonFoster  
Started by MiCe1999, Yesterday, 09:26 PM
0 responses
16 views
0 likes
Last Post MiCe1999  
Working...
X