The Ultra Oscillator is a technical analysis tool designed to provide traders with a smoother, more comprehensive view of price momentum by aggregating multiple data points into a single visual line.
Core Logic and Methodology
Unlike many standard indicators that focus on a single timeframe or a specific moving average, this script utilizes a "cumulative" approach. It works by calculating three distinct Linear Weighted Moving Averages (LWMA) simultaneously and combining them to determine its final output.
The logic follows these specific steps:
- Data Selection: The tool focuses on the "Closing Price" of each candle or price bar. This is often considered the most reliable data point for determining where the market sentiment settled during a specific period.
- Multi-Layered Analysis: Instead of looking at just one trend, the script calculates three different trends based on three different time horizons:
- A short-term average (7 periods) to capture immediate price action.
- A medium-term average (14 periods) to identify broader momentum.
- A longer-term average (28 periods) to establish the prevailing trend.
- Weighting: By using a "Linear Weighted" method, the script gives more importance to recent price action while still considering historical data. This helps filter out minor market "noise" while remaining responsive to significant price shifts.
- Aggregation: The final value shown on your chart is the sum of these three averages. By adding them together, the indicator creates a compounded view of the market. If all three averages are moving in the same direction, the oscillator will show a stronger, more pronounced movement; if they conflict, the indicator provides a balanced representation of the underlying price pressure.
Visual Representation
The result is displayed as a continuous green line in a separate window below your main price chart. This allows you to observe the "pulse" of the market independently of the price fluctuations, making it easier to identify shifts in momentum and potential trend changes without the visual clutter of the main price action.
//+------------------------------------------------------------------+
//| Ultra Oscillator.mq4 |
//| Yuriy Tokman (YTG) |
//| http://ytg.com.ua/ |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link "http://ytg.com.ua/"
#property version "1.00"
#property strict
#property indicator_separate_window
//---
#property indicator_buffers 1
#property indicator_color1 Green
//---
double B0[];
int shift_begin=28;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
IndicatorShortName("Ultra Oscillator");
SetIndexBuffer(0,B0);
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(0,shift_begin);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
//---
int limit=rates_total-prev_calculated;
if(prev_calculated==0)limit--;
else limit++;
//---
for(int i=0; i<limit && !IsStopped(); i++)
B0[i]=iMA(Symbol(),0,7,0,MODE_LWMA,PRICE_CLOSE,i)+
iMA(Symbol(),0,14,0,MODE_LWMA,PRICE_CLOSE,i)+
iMA(Symbol(),0,28,0,MODE_LWMA,PRICE_CLOSE,i);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Comments