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

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 mattbsea, Today, 05:44 PM
      0 responses
      3 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,282 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      20 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Working...
      X