azzx_sma_rsi_1_0
Download scriptThis custom indicator is designed to provide traders with a visual representation of market momentum, specifically focusing on the balance between buying and selling pressure over a specific timeframe. Unlike standard technical indicators that might rely on complex smoothing, this tool focuses on the raw price action of individual candles to determine market sentiment.
Core Logic and Methodology
The script analyzes the price movements by looking at the difference between the "Open" and "Close" prices of each candlestick within a user-defined period (defaulting to 9).
Here is how the logic processes that data:
- Price Differentiation: For every candle in the designated period, the tool calculates the distance traveled. If a candle closed higher than it opened (an upward move), it is categorized as positive momentum. If it closed lower (a downward move), it is categorized as negative momentum.
- Momentum Aggregation: The script sums up all the "up" movements and all the "down" movements separately. By isolating these two forces, the indicator can determine which side—buyers or sellers—has been more dominant during that timeframe.
- Percentage Calculation: To make this data readable, the tool converts the raw price changes into a percentage scale ranging from 0 to 100. It calculates what portion of the total movement was driven by upward pressure versus downward pressure.
- Visual Representation: This result is plotted in a separate window on your chart. A value closer to 100 indicates that bullish (upward) movements have significantly outweighed bearish ones, while a value closer to 0 suggests that selling pressure has been the primary driver.
Key Features for Traders
- Customizable Sensitivity: Users can adjust the "Period" setting. A shorter period makes the indicator more sensitive to rapid, immediate price changes, while a longer period provides a broader view of the trend.
- Standard Reference Levels: The tool includes predefined visual levels at 30 and 70. These are commonly used by traders to identify "overbought" or "oversold" conditions—essentially alerting you when the market might be reaching an extreme point in one direction.
- Clean Data Processing: The script is programmed to ignore insufficient data points, ensuring that the visual lines on your chart only appear once there is enough historical information to provide a meaningful calculation.
// ---------------------------------------------------------------------------
// Ðàññ÷¸ò RSI ïî êíèãå ×.Ëåáî è Ä.Ëóêàñà, äëÿ óñðåäíåíèÿ èñïîëüçóåòñÿ SMA.
// ---------------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 30
#property indicator_level2 70
// Ïåðèîä èíäèêàòîðà.
extern int PERIOD = 9;
// Áóôåðû èíäèêàòîðà.
double buf_rsi[];
// Ðàáî÷èé ïåðèîä èíäèêàòîðà.
int work_period;
// Èíèöèàëèçàöèÿ.
int init() {
IndicatorShortName(StringConcatenate(
"AZZX - SMA RSI v1.0 (", PERIOD, ")"));
IndicatorDigits(0);
SetIndexBuffer(0, buf_rsi);
SetIndexEmptyValue(0, -1);
SetIndexLabel(0, "SMA RSI(" + PERIOD + ")");
work_period = Bars - PERIOD;
return(0);
}
// Ãëàâíûé öèêë.
int start() {
int i;
for(i = Bars - IndicatorCounted() - 1; i >= 0; i--) {
if(i < work_period) {
double up = 0, dn = 0;
int j;
for(j = i + PERIOD - 1; j >= i; j--) {
double v = Close[j] - Open[j];
if(v > 0) {
up += v;
} else {
dn -= v;
}
}
buf_rsi[i] = up / (up + dn) * 100;
} else {
buf_rsi[i] = -1;
}
}
return(0);
}
Comments