Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EMA question

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

    EMA question

    I have this script I'm trying to run - the first line works OK. But the second line won't process right. Is it the .bars on the EMA ?

    Slopeup is a varible

    // Condition set 1
    if ( (High[0] >= (Bollinger(2, 14).Upper[0] + (1 * TickSize )))
    && (EMA(12).Bars[0] <= EMA(12).Bars[1] + (Slopeup * TickSize))
    && ((ToTime(Time[0]) >= 83000) && (ToTime(Time[0]) <= 150000 )))
    {
    EnterShort(DefaultQuantity, "Short-One");
    }

    #2
    What are you trying to check with .Bars? Are you trying to look at an added array?

    Or are you just looking at a single series script and trying to get previous EMA values?
    MatthewNinjaTrader Product Management

    Comment


      #3
      EMA question

      Well, I really just want to check the curent bars EMA value with the same EMA value say, one or two bars ago. To get an idea of the slope of the EMA line the idea being if its trending you don't want to trade against it.

      Comment


        #4
        Hello,

        Thanks for your note.

        You can access the EMA for a particular bar without using the .Bars.

        For example:

        if (EMA(12)[0] > EMA(12)[1])

        will check that the EMA of the current bar is higher than the EMA of 1 bar ago.


        Please let me know if this does not resolve your inquiry.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          EMA question

          OK, but I want to know by how much.
          So, I want to:
          if( EMA(12)[0] - EMA(12)[1] )

          but that doesn't seem to process correctly.

          Comment


            #6
            Originally posted by Joe Average View Post
            OK, but I want to know by how much.
            So, I want to:
            if( EMA(12)[0] - EMA(12)[1] )

            but that doesn't seem to process correctly.
            Open the output window, and use the Print command before your if statement to see what is going on.

            Print ( "ema12[0]=" + EMA(12)[0] );
            Print ( "ema12[1]=" + EMA(12)[1]);
            Print ( "Difference=" + ( EMA(12)[0] - EMA(12)[1]) );

            Comment


              #7
              Originally posted by Joe Average View Post
              OK, but I want to know by how much.
              So, I want to:
              if( EMA(12)[0] - EMA(12)[1] )

              but that doesn't seem to process correctly.
              That is because the statement means nothing that can be processed. Say what you are trying to say in words, and someone will show you how to write it. "if the 12 period EMA on this bar minus the 12 period EMA on the previous bar" is not an actionable statement. That is the entirety of what your statement says.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CaptainJack, 04-24-2026, 11:07 PM
              0 responses
              17 views
              0 likes
              Last Post CaptainJack  
              Started by Mindset, 04-21-2026, 06:46 AM
              0 responses
              120 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by M4ndoo, 04-20-2026, 05:21 PM
              0 responses
              174 views
              0 likes
              Last Post M4ndoo
              by M4ndoo
               
              Started by M4ndoo, 04-19-2026, 05:54 PM
              0 responses
              92 views
              0 likes
              Last Post M4ndoo
              by M4ndoo
               
              Started by cmoran13, 04-16-2026, 01:02 PM
              0 responses
              134 views
              0 likes
              Last Post cmoran13  
              Working...
              X