Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I make Keltner RSI?

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

    How can I make Keltner RSI?

    The Keltner RSI uses the simple moving average, whereas Wilder's RSI, as provided by NinjaTrader, employs Wilder's moving average (similar to EMA).

    I attempted to create a Keltner RSI indicator using the NinjaScript editor, but I encountered repeated challenges.

    Below is the logic I devised for the Keltner RSI. Instead of using the closing price (C), I utilized the Typical Price (T), defined as:
    T = (C + H + L) / 3

    The formula for Keltner RSI is as follows:
    RSI(Period) = 100 * [Sum(if (T - T(1) > 0, T - T(1), 0), Period)] / [Sum(if (T - T(1) > 0, T - T(1), T(1) - T), Period)]


    Explanation:
    1. Upward Changes:
      Sum(if (T - T(1) > 0, T - T(1), 0), Period)
      • If the current Typical Price (T) is higher than the previous bar’s Typical Price (T(1)), add the difference (T - T(1)).
      • Otherwise, add 0. This represents the sum of upward changes over the period.
    2. Upward + Downward Changes:
      Sum(if (T - T(1) > 0, T - T(1), T(1) - T), Period)
      • If the current Typical Price (T) is higher than the previous bar’s Typical Price (T(1)), add the difference (T - T(1)).
      • Otherwise, add the absolute difference in reverse order (T(1) - T).
      • This results in the total of upward and downward changes over the period.
    3. RSI Calculation (Upward/Total Changes):
      Divide the sum of upward changes (Section 1) by the total changes (Section 2), and multiply the result by 100 to convert it into a percentage.


    Is there any way to make Ninjascript indicator that follows above logic?




    #2
    Hello hybinubt,

    Below is a link to a support article with helpful resources on getting started with C# and NinjaScript.


    What challenges are you having?
    What have you coded so far?

    This doesn't appear to be NinjaScript or C#. Is this written in a different language?

    Where you have:
    T = (C + H + L) / 3

    I think this translates to:
    MyTypicalSeries[0] = (Close[0] + High[0] + Low[0]) / 3;

    Where you have:
    RSI(Period) = 100 * [Sum(if (T - T(1) > 0, T - T(1), 0), Period)] / [Sum(if (T - T(1) > 0, T - T(1), T(1) - T), Period)]

    I think this translates to:
    Value[0] = 100 * new int[] { Math.Max(0, MyTypicalSeries[0] - MyTypicalSeries[1]), Period }.Sum() / new int[] { Math.Max(0, MyTypicalSeries[1] - MyTypicalSeries[0]), Period }.Sum();
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    52 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    38 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    99 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    60 views
    0 likes
    Last Post PaulMohn  
    Working...
    X