OsMA

This tool is a specialized technical analysis indicator designed to provide traders with a clearer picture of market momentum by smoothing out the fluctuations often seen in standard oscillators. It functions by layering three different mathematical calculations to distill complex price movements into a single, easy-to-read histogram.

How the Logic Works

The script operates through a three-step calculation process to determine the final output shown on your chart:

1. Identifying Momentum (The Foundation) First, the tool looks at two different "Moving Averages"—essentially averages of past prices over specific timeframes (set by the Fast and Slow parameters). By subtracting the slower average from the faster one, the script determines the current "velocity" of the market. This tells us whether the price is accelerating or decelerating.

2. Creating a Signal Baseline Instead of looking at just the raw velocity, the tool takes that result and applies a third smoothing layer (the Signal line). This step acts as a stabilizer; it filters out minor "noise" or temporary price spikes, making it easier to see the broader trend of the momentum rather than getting distracted by every tiny fluctuation.

3. The Final Calculation (The Histogram) The final value you see on your screen is the result of subtracting that stabilized Signal line from the raw Momentum. This difference is plotted as a histogram.

What This Means for the Trader

By combining these three steps, the script creates a "Moving Average of an Oscillator." The primary goal is to provide a visual representation of market strength that is less "jittery" than standard indicators. Because it uses multiple layers of smoothing:

  • It helps highlight significant shifts in trend direction.
  • It reduces the frequency of false signals caused by minor price volatility.
  • It provides a clearer view of whether the current market move has enough "weight" to sustain itself or if it is losing steam.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
OsMA
//+------------------------------------------------------------------+
//|                                                         OsMA.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Silver
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];
double     ind_buffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexDrawBegin(0,SignalSMA);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- 3 indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) &&
      !SetIndexBuffer(1,ind_buffer2) &&
      !SetIndexBuffer(2,ind_buffer3))
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("OsMA("+FastEMA+","+SlowEMA+","+SignalSMA+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Average of Oscillator                                     |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      ind_buffer2[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd additional buffer
   for(i=0; i<limit; i++)
      ind_buffer3[i]=iMAOnArray(ind_buffer2,Bars,SignalSMA,0,MODE_SMA,i);
//---- main loop
   for(i=0; i<limit; i++)
      ind_buffer1[i]=ind_buffer2[i]-ind_buffer3[i];
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments