Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating RSI of an average and then using value as a variable for a new indicator.

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

    Calculating RSI of an average and then using value as a variable for a new indicator.

    I use an indicator that is based upon John Ehler's Inverse Fisher Transform.

    I have the code in Easy Language and Thinkscript, but have not yet converted it to Ninjascript. Before I go through the process of attempting to convert it though, I'd like to know if it's even possible to calculate the RSI value of a smoothed price average of the bar close instead of the RSI value of just the close and then use that calculated value as part of an equation, the result of the equation being that which is plotted. I'm pretty sure it's possible to do this, but I just want to make sure, before I start converting and end up hanging myself out of frustration because it ends up being not possible.

    This is a simplified version, in easy language, of what I'm using.
    Parts of the code that I'm wondering about are in bold.


    inputs: RSILength(1);
    inputs: EMALength(1);

    vars: SIF(0);
    value3 = WAverage (close, 3);
    value4 = WAverage (value3, 3);
    value5 = XAverage (value4, 3);

    value 6 = (5 * value3+4 * value4 + value5) / 20;

    value7 = .1*(RSI(value 6, RSILength) - 50);

    value8 = XAverage (value7, EMALength);
    value9 = XAverage (value8, EMALength);
    value10 = (value8 - value9);
    value11 = (value8 + value10);

    SIF = (ExpValue(2*value11) -1) / (ExpValue(2*value11) + 1);

    Plot1(SIF, "SIF");



    One other question I have is, are there already built in functions for things like XAverage (exponentially weighted moving average) or will I need to build a function myself?
    I know that ninjascript is based on C# so should I assume all functions from C# are present in ninjascript, or is there a manual I should look for elsewhere?

    #2
    Originally posted by Э_Стайли View Post
    I use an indicator that is based upon John Ehler's Inverse Fisher Transform.

    I have the code in Easy Language and Thinkscript, but have not yet converted it to Ninjascript. Before I go through the process of attempting to convert it though, I'd like to know if it's even possible to calculate the RSI value of a smoothed price average of the bar close instead of the RSI value of just the close and then use that calculated value as part of an equation, the result of the equation being that which is plotted. I'm pretty sure it's possible to do this, but I just want to make sure, before I start converting and end up hanging myself out of frustration because it ends up being not possible.

    This is a simplified version, in easy language, of what I'm using.
    Parts of the code that I'm wondering about are in bold.


    inputs: RSILength(1);
    inputs: EMALength(1);

    vars: SIF(0);
    value3 = WAverage (close, 3);
    value4 = WAverage (value3, 3);
    value5 = XAverage (value4, 3);

    value 6 = (5 * value3+4 * value4 + value5) / 20;

    value7 = .1*(RSI(value 6, RSILength) - 50);

    value8 = XAverage (value7, EMALength);
    value9 = XAverage (value8, EMALength);
    value10 = (value8 - value9);
    value11 = (value8 + value10);

    SIF = (ExpValue(2*value11) -1) / (ExpValue(2*value11) + 1);

    Plot1(SIF, "SIF");



    One other question I have is, are there already built in functions for things like XAverage (exponentially weighted moving average) or will I need to build a function myself?
    I know that ninjascript is based on C# so should I assume all functions from C# are present in ninjascript, or is there a manual I should look for elsewhere?
    In NT, Exponential Moving Average is simply the EMA() class/indicator. Yes, you can use the output of one indicator as the input of another to any nested depth.

    Comment


      #3
      Your indicator is the inverse Fisher Transform of a double exponential moving average of a compressed, shifted RSI. With NinjaTrader you would need to declare a DataSeries rsiSeries and a variable smoothed RSI. In OnBarUpdate() the following three lines of code would be sufficient, making it one of the shortest NinjaTrader indicators:

      Code:
      rsiSeries.Set(0.1*(RSI(rsiPeriod,1)[0]-50));
      smoothedRSI = DEMA(rsiSeries, demaPeriod)[0];
      Value.Set((Math.Exp(2*smoothedRSI)-1)/(Math.Exp(2*smoothedRSI)+1));
      There is a similar version available for NinjaTrader, which uses the weighted moving average instead of the double exponential moving average. Search for "Inverse Fisher Transform".

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X