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

Creating a Dynamic Threshold for RSI

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

    Creating a Dynamic Threshold for RSI

    Using RSI as a tool for identifying over-bought or over-sold markets is useful when markets are range-bound. But when a market wants to make a sustained one-directional move, RSI will generate a lot of false signals on the opposite side of that move.

    On the other hand, in such a strong-trending market, RSI typically can't reach its threshold on the side of that sustained move. For example, if your usual threshold for a sell-side entry is, say, 90, when market is moving strongly downward, RSI rarely will reach 85-88.

    I would like to build in to my strategy recognition of that concept. So, my idea is this:

    By defining a Lookback int variable, which would specify a look-back period, I would like my strategy to test whether market has reached that usual SignalThreshold (a double variable) during the Lookback period. If it has not, I then would like my strategy to adjust SignalThreshold by some amount (for example, 2 increments).

    My question is this:

    How do I code such a contingency into an existing strategy? That is, by using the sell side as an example, if market has not attained SignalThreshold during the Lookback period, adjust SignalThreshold to SignalThreshold - 2.

    I have tried amending my strategy to include the following, but it won't compile:

    {

    if (MAX(RSI(xx,xx),Lookback)[0] < SignalThreshold)

    SignalThreshold == SignalThreshold - 2.0;

    }

    else if ....

    Am I on the wrong track to accomplish what I want?

    #2
    Hi Longhornmark,

    Thanks for your post.

    I think the MRO() method will be useful for finding this, the MAX method is also a solution. What part of that will not compile? It looks like you just have "xx" for the parameters of RSI you must supply two integers, a period value and a smoothing value.

    Please let me know if I can assist further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      You want '=' instead of '=='

      Also, this is equivalent and a shorter way of writing it: SignalThreshold -= 2.0;

      *Not sure if those parentheses are in your real code, but they are surrounding the 'if' statement, so you wouldn't be able to link an 'else if' to it.

      This would fix it:

      if (MAX(RSI(xx,xx),Lookback)[0] < SignalThreshold)
      {
      SignalThreshold = SignalThreshold - 2.0;
      }
      else if..
      Last edited by anon84; 05-23-2019, 10:24 AM. Reason: parentheses

      Comment


        #4
        Indeed, it did compile with your simple edit! Thanks for your help!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rdtdale, Today, 01:02 PM
        0 responses
        1 view
        0 likes
        Last Post rdtdale
        by rdtdale
         
        Started by alifarahani, Today, 09:40 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by RookieTrader, Today, 09:37 AM
        4 responses
        18 views
        0 likes
        Last Post RookieTrader  
        Started by PaulMohn, Today, 12:36 PM
        0 responses
        6 views
        0 likes
        Last Post PaulMohn  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        40 views
        0 likes
        Last Post love2code2trade  
        Working...
        X