Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing Events in Mutiple Time Frames

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

    Referencing Events in Mutiple Time Frames

    I have a strategy that uses 2 timeframes (both 'volume' charts) and I am trying to use an event from BarsArray[1] to trigger a close to an open position in BarsArray[0].

    The event in [1] is when 2 ema's cross.

    I have successfully referenced indicator "values" between MTF bars, but can't seem to reference events.

    My thought now is that I need to do something like this: (i left out non-relavent parts of the code for clarity)

    if(BarsInProgress==1 && Crossover(EMA1,EMA2,1))
    {
    myVariable = 1;
    }
    else
    {
    myVariable =0;
    }

    if(BarsinProgress==0)
    {
    if(myVariable = 1)
    {
    ExitLong
    }
    }

    Is this the best way to do this? Or am I simply missing the right Syntax to reference the event directly within the code in "BarsInProgress==0"? I am not sure the 2 Bars are sync'd so that the crossover event that occurred at the close of the last bar in [1] is still valid when the update happens in [0].

    I may have simply missed an example of an event vs. an indicator in the documentation.

    THX.
    Jim-Boulder
    NinjaTrader Ecosystem Vendor - Elephant Tracks

    #2
    Hi Jim,

    A few comments assuming that both time frames are the same instrument -

    - You have reached a current limitation with NT6 in that you must place your order in the context of the primary series ([0]) and to fully realize what you want, it would be best to submit the order from context [1]. We will support this with beta end of summer

    - To get around this, there are several things that you can do:

    1) The above sample you provided would work

    2) You could do something like:

    if (BarsInProgress == 0 && CrossAbove(EMA(BarsArray[1], Period), EMA(BarsArray[1], Period2), 1))
    {
    ExitLong();
    }

    Either approach I suspect will yield the same result. The value returned by CrossAbove() will be true for the last closed bar of the second series when calculate on bar close is set to true and during backtest, or on the most current bar in formations OHLC values in real-time if calculate on bar close is set to false.
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    567 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 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
    548 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X