Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Comparing to Indicators

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

    Comparing to Indicators

    hi,

    I am having trouble with comparing relative prices.


    For example,

    if SMA(5) < SMA(5) -10 pips



    I tried the below and it does not work:

    if (SMA(5)[0] < SMA(5)[0] - 10 * TickSize)

    #2
    Hi Faspomy,

    That condition will always be false. It's sort of like saying:

    if (5 < 5 - 2)

    Can you describe in English what you're trying to express?
    Last edited by NinjaTrader_RyanM1; 03-30-2011, 12:50 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Faspomy View Post
      hi,

      I am having trouble with comparing relative prices.


      For example,

      if SMA(5) < SMA(5) -10 pips



      I tried the below and it does not work:

      if (SMA(5)[0] < SMA(5)[0] - 10 * TickSize)
      That expression is identically false, so whatever is conditioned on it will never trigger.

      Comment


        #4
        Thank you.

        Can you describe in English what you're trying to express?
        Yes-- an offset.
        I would like to compare one SMA value to another SMA value which is offset by a preset value.
        It's essentially saying "If the price drops under 20 pips below the SMA(30), do this".

        Comment


          #5
          That expression is identically false, so whatever is conditioned on it will never trigger.

          Thank you.
          Can I re-bracket the condition like below ?

          if (SMA(5)[0] < (SMA(5)[0] - 10 * TickSize))

          Comment


            #6
            I would like to compare one SMA value to another SMA value which is offset by a preset value.
            It's essentially saying "If the price drops under 20 pips below the SMA(30), do this"
            The issue with your snippet compared to the description is that you're comparing the same sma value to itself offset.

            Comparing price is different, so you can say:
            if (Close[0] < SMA(30)[0] - TickSize * 20)
            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
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X