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 CarlTrading, 03-31-2026, 09:41 PM
              1 response
              31 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, Yesterday, 02:41 AM
              0 responses
              14 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              22 views
              1 like
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              40 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              34 views
              0 likes
              Last Post CarlTrading  
              Working...
              X