OsMAII

This custom technical indicator is designed to provide traders with a smoothed, refined visualization of market momentum. It operates by layering three different types of mathematical averages to filter out "market noise," helping users identify more reliable trends and potential turning points in price action.

How the Logic Works

The tool processes data in three distinct stages to arrive at its final visual output:

1. Calculating the Core Momentum First, the script looks at the speed of price movement by comparing two different "Exponential Moving Averages." One is set to a faster timeframe (to capture immediate changes) and the other to a slower timeframe (to capture the broader trend). By subtracting the slow average from the fast one, the script identifies the current strength and direction of the market's momentum.

2. Creating the Signal Baseline Once the initial momentum is established, the script performs a second calculation. It takes that raw momentum data and applies a "Simple Moving Average" to it. This acts as a smoothing agent, creating a secondary baseline or "signal line." The goal of this step is to stabilize the data so that minor, insignificant price fluctuations do not create false signals.

3. Final Output Construction The final value displayed on your chart is the result of subtracting the smoothed signal line from the core momentum data. By comparing these two values at the end of the process, the indicator provides a polished representation of market sentiment.

Practical Application for the User

Instead of looking at raw price spikes which can be erratic, this logic allows you to see a consolidated trend. When the resulting line moves significantly above or below the center zero-level, it indicates a strengthening trend in that direction. Because the script uses multiple layers of averaging, it aims to provide a cleaner, more stable visual than standard momentum oscillators, helping you distinguish between a temporary price "hiccup" and a sustained move.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
OsMAII
//+------------------------------------------------------------------+
//|                                                       OsMAII.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  Red
#property  indicator_level1  0

//---- 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_LINE,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("OsMAII("+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