The Quinex RSI Stochastic V1.2 (Non-Repaint) is a custom technical analysis indicator designed to help traders assess market momentum by combining the Relative Strength Index (RSI) and Stochastic Oscillator. This indicator operates within a separate window and provides insights into potential overbought and oversold conditions. By analyzing price movements and smoothing them with moving averages, the Quinex RSI Stochastic aids in identifying possible trend reversals. It offers flexibility through adjustable parameters, allowing traders to tailor the settings to their specific strategies.
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots 1
#property indicator_label1 "SVE Stochastic Rsi"
#property indicator_type1 DRAW_COLOR_LINE
#property indicator_color1 clrDarkGray, clrMediumSeaGreen, clrOrangeRed
#property indicator_width1 2
// Input parameters for the indicator
input int inpRsiPeriod = 21; // RSI period
input ENUM_APPLIED_PRICE inpPrice = PRICE_CLOSE; // Price
input int inpStoPeriod = 8; // Stochastic period
input int inpAvgPeriod = 5; // Average period
double val[], valc[], rsi[]; // Indicator buffers
//------------------------------------------------------------------
// Custom indicator initialization function
//------------------------------------------------------------------
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0, val, INDICATOR_DATA);
SetIndexBuffer(1, valc, INDICATOR_COLOR_INDEX);
SetIndexBuffer(2, rsi, INDICATOR_CALCULATIONS);
iRsi.init(inpRsiPeriod); // Initialize RSI calculation
avgRsiLow.init(inpAvgPeriod); // Initialize average low calculation
avgHighLow.init(inpAvgPeriod); // Initialize average high-low calculation
//--- indicator short name assignment
IndicatorSetString(INDICATOR_SHORTNAME, "Stochastic RSI (" + (string)inpRsiPeriod + "," + (string)inpStoPeriod + "," + (string)inpAvgPeriod + ")");
return (INIT_SUCCEEDED);
}
void OnDeinit(const int reason) { }
//------------------------------------------------------------------
// Custom indicator iteration function
//------------------------------------------------------------------
#define _setPrice(_priceType, _target, _index) \
{ \
switch (_priceType) \
{ \
case PRICE_CLOSE: _target = close[_index]; break; \
case PRICE_OPEN: _target = open[_index]; break; \
case PRICE_HIGH: _target = high[_index]; break; \
case PRICE_LOW: _target = low[_index]; break; \
case PRICE_MEDIAN: _target = (high[_index] + low[_index]) / 2.0; break; \
case PRICE_TYPICAL: _target = (high[_index] + low[_index] + close[_index]) / 3.0; break; \
case PRICE_WEIGHTED: _target = (high[_index] + low[_index] + close[_index] + close[_index]) / 4.0; break; \
default: _target = 0; \
} \
}
//------------------------------------------------------------------
// Calculate indicator values
//------------------------------------------------------------------
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
static int prev_i = -1;
static double prev_max = 0, prev_min = 0;
int i = prev_calculated - 1;
if (i < 0) i = 0;
for (; i < rates_total && !_StopFlag; i++)
{
double _price;
_setPrice(inpPrice, _price, i); // Set the price based on selected type
rsi[i] = iRsi.calculate(_price, i); // Calculate RSI value
if (prev_i != i)
{
prev_i = i;
int start = i - inpStoPeriod + 1;
if (start < 0) start = 0;
// Determine max and min RSI values in the specified range
prev_max = rsi[ArrayMaximum(rsi, start, inpStoPeriod - 1)];
prev_min = rsi[ArrayMinimum(rsi, start, inpStoPeriod - 1)];
}
double max = (rsi[i] > prev_max) ? rsi[i] : prev_max;
double min = (rsi[i] < prev_min) ? rsi[i] : prev_min;
// Calculate averages
double _avgRsiLow = avgRsiLow.calculate(rsi[i] - min, i, rates_total);
double _avgHighLow = avgHighLow.calculate(max - min, i, rates_total);
// Calculate values for the indicator buffers
val[i] = (_avgHighLow != 0) ? 100 * _avgRsiLow / _avgHighLow : 0;
valc[i] = (i > 0) ? (val[i] > val[i - 1]) ? 1 : (val[i] < val[i - 1]) ? 2 : valc[i - 1] : 0;
}
return (i);
}
//------------------------------------------------------------------
// Custom functions
//------------------------------------------------------------------
class cRsi
{
private:
int m_period; // RSI period
int m_arraySize; // Size of the working array
double m_alpha; // Smoothing factor
struct sRsiArray
{
double price; // Current price
double change1; // Previous change
double changa1; // Previous absolute change
double change; // Current change
double changa; // Current absolute change
};
sRsiArray m_work[]; // Array to store RSI calculations
public:
cRsi() : m_period(1), m_alpha(1), m_arraySize(33)
{
ArrayResize(m_work, 33);
return;
}
~cRsi()
{
ArrayFree(m_work);
return;
}
// Initialize the RSI calculation
void init(int period)
{
m_period = (period > 1) ? period : 1;
m_arraySize = m_period + 32;
m_alpha = 1.0 / MathSqrt(m_period);
ArrayResize(m_work, m_arraySize);
}
// Calculate the RSI value
double calculate(double price, int i)
{
int _indC = (i) % m_arraySize;
m_work[_indC].price = price;
if (i > m_period)
{
int _indP = (_indC - 1);
if (_indP < 0) _indP += m_arraySize;
double change = m_work[_indC].price - m_work[_indP].price;
double changa = change;
if (change < 0) changa = -change;
m_work[_indC].change1 = m_work[_indP].change1 + m_alpha * (change - m_work[_indP].change1);
m_work[_indC].change = m_work[_indP].change + m_alpha * (m_work[_indC].change1 - m_work[_indP].change);
m_work[_indC].changa1 = m_work[_indP].changa1 + m_alpha * (changa - m_work[_indP].changa1);
m_work[_indC].changa = m_work[_indP].changa + m_alpha * (m_work[_indC].changa1 - m_work[_indP].changa);
}
else
{
m_work[_indC].changa = 0;
for (int k = 0; i > k; k++)
{
m_work[_indC].changa += m_work[_indC - k].price > m_work[_indC - k - 1].price ?
m_work[_indC - k].price - m_work[_indC - k - 1].price :
m_work[_indC - k - 1].price - m_work[_indC - k].price;
}
m_work[_indC].changa /= (i + 1.0);
m_work[_indC].change = (m_work[_indC].price - m_work[0].price) / (i + 1.0);
m_work[_indC].change1 = m_work[_indC].change;
}
return (m_work[_indC].changa != 0) ? (50.0 * (m_work[_indC].change / m_work[_indC].changa + 1.0)) : 0;
}
};
cRsi iRsi; // Instance of cRsi class
// Class for calculating SMA
class CSma
{
private:
int m_period; // SMA period
int m_arraySize; // Size of the working array
struct sSmaArrayStruct
{
double value; // Current value
double summ; // Sum of values
};
sSmaArrayStruct m_array[]; // Array to store SMA calculations
public:
CSma() : m_period(1), m_arraySize(-1)
{
return;
}
~CSma()
{
ArrayFree(m_array);
return;
}
// Initialize the SMA calculation
void init(int period)
{
m_period = (period > 1) ? period : 1;
m_arraySize = m_period + 1;
ArrayResize(m_array, m_arraySize);
}
// Calculate the SMA value
double calculate(double price, int i, int rates_total)
{
int _index = i % m_arraySize;
m_array[_index].value = price;
if (i < m_period)
{
double sum = 0;
for (int j = 0; j <= i; j++)
sum += m_array[j % m_arraySize].value;
m_array[_index].summ = sum / (i + 1);
}
else
{
m_array[_index].summ = (m_array[_index].summ * m_period - m_array[(i - m_period) % m_arraySize].value + price) / m_period;
}
return m_array[_index].summ;
}
};
CSma avgRsiLow; // Instance of average low class
CSma avgHighLow; // Instance of average high-low class
What is the Quinex RSI Stochastic Indicator?
The Quinex RSI Stochastic indicator is a custom technical analysis tool that operates within a separate window on your trading platform. Its primary purpose is to provide a clearer view of the momentum of an asset, helping traders make informed decisions based on market conditions.
Key Components
- Relative Strength Index (RSI):
- The RSI is a momentum oscillator that measures the speed and change of price movements. It ranges from 0 to 100, helping traders identify whether an asset is overbought or oversold.
- Stochastic Oscillator:
- This component compares a specific closing price of an asset to a range of its prices over a set period. It also ranges from 0 to 100 and is used to find potential reversal points.
- Moving Average:
- The indicator uses moving averages to smooth out the price data, providing a clearer signal by reducing noise.
How Does the Indicator Work?
The Quinex RSI Stochastic combines the RSI and Stochastic Oscillator to produce a single line that indicates market momentum. Here’s how it functions:
- Input Parameters:
- Traders can adjust various parameters such as the RSI period, Stochastic period, and average period to customize the indicator according to their trading strategies.
- Buffer Arrays:
- The indicator utilizes buffer arrays to store calculated values. These buffers are essential for displaying the indicator line and its changes over time.
- Calculations:
- The indicator calculates the RSI and Stochastic values based on the selected price type (e.g., close, open, high, or low) and the defined periods. These calculations help determine the momentum and potential reversals in the asset price.
Indicator Values and Signals
- Overbought and Oversold Levels:
- Typically, values above 70 indicate an overbought condition, while values below 30 suggest an oversold condition. Traders often use these levels to identify potential entry and exit points.
- Trend Reversals:
- When the Quinex RSI Stochastic crosses above the overbought line or below the oversold line, it may signal a potential trend reversal, indicating a good opportunity to buy or sell.
Interpreting the Indicator
Visual Representation
The Quinex RSI Stochastic is visually represented in a separate window, often using color-coded lines. Traders can easily observe the line’s movement in relation to overbought and oversold levels.
Making Trading Decisions
- Entry Points:
- A trader might consider entering a trade when the indicator shows a cross below the oversold level, suggesting a potential upward reversal.
- Exit Points:
- Conversely, if the indicator crosses above the overbought level, it could be an opportunity to exit a position, anticipating a downward move.
Conclusion
The Quinex RSI Stochastic indicator serves as a valuable tool for traders seeking to enhance their technical analysis. By blending the principles of the RSI and Stochastic Oscillator, it offers insights into market momentum and potential reversal points. While using this indicator, it’s essential to remember that no indicator guarantees success; it should be used in conjunction with other analysis methods for best results. By understanding the components and functionalities of the Quinex RSI Stochastic, traders can make more informed decisions and improve their overall trading strategies.