Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar/ EMA Crossover Indicator

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

    Bar/ EMA Crossover Indicator

    Hello everybody. This is my first post on this forum, so please be gentle;
    I am trying to create an indicator which will be used in Market Analyzer to trigger an alert when conditions specified are present: previous bar crossing three EMA's. Calculated on bar close. Relationship between EMA's, their shape or slope irrelevant. Following the teachings in the help manual I wrote the script:
    // plot below by replacing 'Close[0]' with your own formula.

    Plot0.Set((Close[1] > Open[1]
    && Open[1] < EMA(4)[1]
    && Close[1] > EMA(4)[1]
    && Open[1] < EMA(8)[1]
    && Close[1] > EMA(8)[1]
    && Open[1] < EMA(21)[1]
    && Close[1] > EMA(21)[1]) ? 1 : 0);
    It went smoothly thru compile process and indicator shows in indicator list, however it will not plot on chart nor trigger alert in Market Analyzer. In MA it just prints current price instead 1's for true, 0's for false. I've attached two screen images to illustrate.Kindly please advise...
    Attached Files
    Last edited by peter@cleaniq; 02-22-2010, 05:23 PM.

    #2
    Hello Peter,

    Welcome to our forums.

    Most likely you are running into the issue below:
    Make sure you have enough bars in the data series you are accessing

    Try adding this statement in the OnBarUpdate() method.
    if (CurrentBar <= 22)
    return;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Bar/ EMA Crossover Indicator

      Thank you Ryan for your help. Is the # of bars arbitrary? I noticed that Moving Averages and Volume don't print for the first 20 bars unless "show unstable.." is true. I need EMA(4),(8),(21) so, at least EMA(4) should start printing after first 4 bars and then EMA(8) should appear after 8 bars etc..It does happen only when "Show Unstable..." is true, that they print from the very first bar. So, there are three EMA's printing while there is not enough bar data to calculate them.After 20 bars there is plenty of data to calculate at least EMA(20) but it also means that on 10' chart we need 3hrs and 20' into the trading day to see real EMA shape and slope. That makes my indicator useless. Again, Thank you for your help and guidance.

      Comment


        #4
        Hi Peter,

        You need the CurrentBar check when NinjaScript will try to access bar objects that don't exist at the beginning of the series. The bar count isn't arbitrary but rather depends on the periods of indicators.

        Show Unstable period will allow you to plot indicators while they are developing, but you still need statements in your code so that NinjaTrader won't try to access non-existing objects.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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