Stochastic RSI

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Re: Stochastic RSI

Postby Apprentice » Sun May 22, 2011 3:24 am

Post, mq4 code you are using.
So we could see the difference.
Out there is a lot of different versions.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Stochastic RSI

Postby station0524 » Sun May 22, 2011 10:43 am

Here is the code,
Code: Select all
Input Parameters:
RSIPeriod = The RSI Period to use (Default 8)
PeriodK = The Stochastic %K period. (Default 8)
SlowPeriod = The final smoothing (slow) value (Default 3)

Revision History

Version 1.0
* Initial Release

Version 1.1 ( 14 Nov 2007 )
* Fixed bug in HHV/LLV calculations to use current bar.  This avoids values > 100
   
*/   


#property copyright "Copyright © 2007, Bruce Hellstrom (brucehvn)"
#property link      "http: //www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2

#property indicator_level1 20.0
#property indicator_level2 80.0
#property indicator_levelcolor Red
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_DOT

#define INDICATOR_VERSION "v1.1"


// Input Parameters
extern int RSIPeriod = 8;
extern int PeriodK = 8;
extern int SlowPeriod = 3;

// Buffers
double RSIBuffer[];
double StochBuffer[];
double TempBuffer[];
bool debug = false;


// Other Variables
string ShortName;


/////////////////////////////////////////////////////////////////////
// Custom indicator initialization function
/////////////////////////////////////////////////////////////////////

int init() {

    IndicatorBuffers( 1 );
    SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 1 );
    SetIndexBuffer( 0, StochBuffer );
    SetIndexDrawBegin( 0, RSIPeriod );
   
    ShortName = "MT4-StochasticRSI-Oscillator-" + INDICATOR_VERSION + " (" + RSIPeriod + "," + PeriodK + "," + SlowPeriod + ")";
   
    IndicatorShortName( ShortName );
    SetIndexLabel( 0, ShortName );
   
    ArraySetAsSeries( RSIBuffer, true );
    ArraySetAsSeries( TempBuffer, true );
   
    Print( ShortName );
    Print( "Copyright (c) 2007 - Bruce Hellstrom, bhweb@speakeasy.net" );
   
    return( 0 );
}

/////////////////////////////////////////////////////////////////////
// Custom indicator deinitialization function
/////////////////////////////////////////////////////////////////////

int deinit() {
    return( 0 );
}

/////////////////////////////////////////////////////////////////////
// Indicator Logic run on every tick
/////////////////////////////////////////////////////////////////////

int start() {
   
    int counted_bars = IndicatorCounted();
   
    // Check for errors
    if ( counted_bars < 0 ) {
        return( -1 );
    }

    // Last bar will be recounted
    if ( counted_bars > 0 ) {
        counted_bars--;
    }

    // Resize the non-buffer array if necessary
    if ( ArraySize( RSIBuffer ) != ArraySize( StochBuffer ) ) {
        ArraySetAsSeries( RSIBuffer, false );
        ArrayResize( RSIBuffer, ArraySize( StochBuffer ) );
        ArraySetAsSeries( RSIBuffer, true );
    }
   
    if ( ArraySize( TempBuffer ) != ArraySize( StochBuffer ) ) {
        ArraySetAsSeries( TempBuffer, false );
        ArrayResize( TempBuffer, ArraySize( StochBuffer ) );
        ArraySetAsSeries( TempBuffer, true );
    }
   
   
    // Get the upper limit
    int limit = Bars - counted_bars;
   
    for ( int ictr = 0; ictr < limit; ictr++ ) {
        RSIBuffer[ictr] = iRSI( NULL, 0, RSIPeriod, PRICE_CLOSE, ictr );
        if ( debug ) {
            if ( RSIBuffer[ictr] > 100.0 ) {
                Print( "Bar: ", ictr, " RSI: ", RSIBuffer[ictr] );
            }
        }
    }

    for ( ictr = 0; ictr < limit; ictr++ ) {
        double llv = LLV( RSIBuffer, PeriodK, ictr );
        double hhv = HHV( RSIBuffer, PeriodK, ictr );
       
        if ( ( hhv - llv ) > 0 ) {
            TempBuffer[ictr] = ( ( RSIBuffer[ictr] - llv ) /
                                 ( hhv - llv ) ) * 100;
            if ( debug && ictr < 100 ) {
                if ( TempBuffer[ictr] > 100.0 ) {
                    Print( "Bar: ", ictr, " TempBuffer: ", TempBuffer[ictr], " RSI: ", RSIBuffer[ictr], " hhv: ", hhv, " llv:", llv );
                }
            }
        }
    }
   
    for ( ictr = 0; ictr < limit; ictr++ ) {
        StochBuffer[ictr] = iMAOnArray( TempBuffer, 0, SlowPeriod, 0, MODE_EMA, ictr );
    }
   
    return( 0 );
}


double LLV( double& indBuffer[], int Periods, int shift ) {
    double dblRet = 0.0;
    int startindex = shift;
   
    for ( int llvctr = startindex; llvctr < ( startindex + Periods ); llvctr++ ) {
        if ( llvctr == startindex ) {
            dblRet = indBuffer[llvctr];
        }
        dblRet = MathMin( dblRet, indBuffer[llvctr] );
    }
   
    return( dblRet );
}

double HHV( double& indBuffer[], int Periods, int shift ) {
    double dblRet = 0.0;
    int startindex = shift;
   
    for ( int hhvctr = startindex; hhvctr < ( startindex + Periods ); hhvctr++ ) {
        if ( hhvctr == startindex ) {
            dblRet = indBuffer[hhvctr];
        }
        dblRet = MathMax( dblRet, indBuffer[hhvctr] );
    }
   
    return( dblRet );
}
station0524
 
Posts: 25
Joined: Sat May 14, 2011 4:30 pm

Re: Stochastic RSI

Postby Alexander.Gettinger » Tue Jul 12, 2011 11:45 pm

Please, see this version of oscillator.

Download:
StochasticRSI.lua
(3.78 KiB) Downloaded 2085 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic RSI

Postby Blackcat2 » Wed Jul 13, 2011 7:18 pm

Alexander.Gettinger wrote:Please, see this version of oscillator.

Download:
StochasticRSI.lua

I think it requires another indicator, could you please tell me where I can get it?

Thanks :)
Blackcat2
FXCodeBase: Initiate
 
Posts: 118
Joined: Wed May 19, 2010 12:42 am

Re: Stochastic RSI

Postby sunshine » Thu Jul 14, 2011 3:09 am

Please install the Averages indicator
http://www.fxcodebase.com/code/viewtopi ... =17&t=2430
sunshine
 

Re: Stochastic RSI

Postby JPNWV7 » Tue Nov 22, 2011 9:09 am

kkhart1935 wrote:I cannot get this to work. I get an error that says to download stochrsi. What am I doing wrong?



I get the same thing
JPNWV7
 
Posts: 17
Joined: Wed Sep 21, 2011 5:56 pm

Re: Stochastic RSI

Postby Alexander.Gettinger » Mon Dec 02, 2013 11:08 am

MQL4 version of Stochastic RSI: viewtopic.php?f=38&t=60051.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic RSI

Postby Apprentice » Sun Dec 06, 2015 4:35 am

Compatibility issue Fix. _Alert helper is not longer needed.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Stochastic RSI

Postby TxChristopher » Thu Aug 11, 2016 10:25 am

Would it be possible for one of you programmers to add a "live" option to this indicator like the "Stochastic with Alert" indicator has? This is a good indicator but the tremendous lag of having to wait for end of turn is especially crippling to it.

The biggest problem with this indicator is once the market starts moving you need to know and waiting for the end of turn often causes losses or missing most of the move, especially in longer time frames obviously because end of turn can be hours away. If this indicator had all the sweet options to alert the trader that the Stochastic with Alert indicator has it would make a huge difference in its usability.

Since they are very similar indicators (but with quite different results often) this would seem like a very easy to do thing.

What say you coders?
TxChristopher
 
Posts: 14
Joined: Tue Nov 12, 2013 4:00 pm

Re: Stochastic RSI

Postby Apprentice » Fri Aug 12, 2016 11:23 am

"live" / "end of turn" option add for "Stochastic RSI with Alert"
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

PreviousNext

Return to Custom Indicators

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 51 guests