Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Indicator Value Rising over number of bars

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

    Indicator Value Rising over number of bars

    Im trying to determine whether the market is trending or ranging using the Strategy Builder. One obvious way would be to look for an inclining/declining EMA/SMA, but if I use rising and falling in the strategy builder doesn't it only tell me whether the bar is rising/falling for the current bar, rather than over a period of time, or X number of bar ago? Basically how do you say 'If SMA/EMA is rising X bars ago?

    Thanks

    #2
    Hello

    Thank you for the post.

    Correct, the IsRising method would report true if the CurrentBar is greater than the Last bar. To make a range of bars which you check if they are rising, you would need to make a price condition.

    For example, checking if the Close 0 Bars Ago is greater than Close 1 BarsAgo would replicate the IsRising. In the same condition, you could add more of those price conditions like Close 1 BarsAgo is greater than Close 2 bars ago and so on. This would create a range of Rising statements.

    The same would apply with Indicators, you would need to create a new condition for each 1 bar span of time you want to compare.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Using a loop would allow the setting of how many bars to include in the test.
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        Hi,

        I have a similar question but I am using the Momentum indicator and used the Double Stochastic as the input. This way I can have bars displayed above and below a zero line.

        My question is: if I want to use the Momentum indicator values as a condition (it will be + or - values from the zero) to determine trend direction? In the strategy builder I compared the indicator to a numerical value, but the negative value are being discarded in the script.

        Any ideas?

        Comment


          #5
          Hello Induna,

          Generally for a trend you would just compare the last plot value against the current, for example if the Current value is greater than the last. What is the numeric value you are using, is it 0?

          If you use the plot instead of a numeric value that would allow for positive or negative values to be used. You can check if the momentum is greater than the previous bars value to see if it increased or decreased. You can include further back data as well to see if a trend is happening for a period of time as we discussed earlier in this thread.


          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Hi,

            yes i am measuring the momentum between a Stochastic 10 period and the previous bar (1). For my condition i want to say that if the value is greater than 0 then only take longs. If the value is less than 0 only take shorts.

            How can I do this with plots instead? Because it is a ratio between two indicators, the decimal values are quite small.

            Comment


              #7
              Hello Induna,

              If you just want to check if its a positive or negative it sounds like you are already doing that for the positive side. For a negative you would do the same and just use a less than 0. What part of the condition for the negative value were you stuck on? I see that the condition to check for less than 0 can be formed, was that not working in some way?

              My prior reply is in regard to a trend as that is what we were previously discussing, I understood your question as you were trying to detect the trend direction for positive or negative. In that case you would not generally want to use a specific numeric value and instead use the previous bars value. It sounds like that is not what you want and instead just need to know if it was positive or negative based on 0.




              I look forward to being of further assistance.



              JesseNinjaTrader Customer Service

              Comment


                #8
                I am looking at the 50 period CCI. around 0 things are a bit unstable so I have specified a threshold of 50 on each side. What I find is when I created the condition when CCI(50)<-50 then in the script it gets rid of the minus and then actions are triggered based on the threshold of 50 and not -50

                In the meantime I am using a 8EMA and 34EMA crossover, which simulates this condition closely, but I would still like to be able to use this function.

                Comment


                  #9
                  Hello Induna,

                  What were the specific steps when you form the condition?

                  I just tried doing the condition you mentioned but I see it can use the negative values.

                  I specifically selected:

                  Left: CCI(50)
                  Center: Less
                  Right: Misc -> Numeric Value -> -50

                  That generated the following syntax:

                  Code:
                  if (CCI1[0] < -50)

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    I will have a look and report back. Thanks!

                    Comment


                      #11
                      I have a similar question regarding trend line actual plot values. How would I go about putting the trend line plot values into a strategy - for example:

                      if the value (let's say for gold) of the plot of the EMA is currently at 995.5 and the value 3 bars back is at 995 (this would indicate the trend line is rising)

                      general syntax for the condition to add to a strategy: if EMA (current bar) > EMA (3 bars back)

                      How would this actually be coded?

                      Comment


                        #12
                        It's okay - someone else answered it for me.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by andrewtrades, Today, 04:57 PM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by chbruno, Today, 04:10 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Started by josh18955, 03-25-2023, 11:16 AM
                        6 responses
                        436 views
                        0 likes
                        Last Post Delerium  
                        Started by FAQtrader, Today, 03:35 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post FAQtrader  
                        Started by rocketman7, Today, 09:41 AM
                        5 responses
                        19 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X