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 traderqz, Today, 12:06 AM
              2 responses
              4 views
              0 likes
              Last Post traderqz  
              Started by RideMe, 04-07-2024, 04:54 PM
              5 responses
              28 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by f.saeidi, Today, 08:13 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by DavidHP, Today, 07:56 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by kujista, Today, 06:23 AM
              3 responses
              11 views
              0 likes
              Last Post kujista
              by kujista
               
              Working...
              X