OsMA Color 1
Download scriptThis tool is designed as a visual momentum indicator for trading platforms, specifically engineered to help traders identify the strength and direction of price movements. It works by analyzing historical price data to create a distinct "histogram" display that highlights whether the market is currently gaining or losing momentum.
Core Mechanics
The logic behind this script operates in three primary stages:
1. Movement Calculation The script begins by calculating a specific type of moving average (similar to the MACD indicator). It looks at two different speeds of price trends—a "Fast" movement and a "Slow" movement—and determines the difference between them. By comparing these two, the tool can identify whether the current price action is accelerating or decelerating compared to the past.
2. Momentum Filtering Once the raw momentum values are calculated, the script performs a comparison check between the current value and the value immediately preceding it. It looks for "turning points"—the exact moments where the momentum begins to shift from positive (upward) to negative (downward), or vice versa.
3. Visual Representation To make this data easy for a human to interpret, the script translates these calculations into a two-colored histogram:
- Green Bars: These represent periods where the momentum is increasing or trending upwards.
- Red Bars: These represent periods where the momentum is decreasing or trending downwards.
How to Interpret the Logic
Instead of just showing raw numbers, this script simplifies market behavior into a clear visual signal. When you see the bars changing color or direction, it indicates a shift in the "power" behind the price movement.
- Strength: The size of the bars indicates how strong the current momentum is.
- Trend Direction: The color and orientation of the bars tell you if that momentum is currently favoring an upward push or a downward slide.
By isolating these movements into a separate window, the script allows traders to see the "pulse" of the market independently of the price candles, making it easier to spot potential reversals or confirm the strength of an existing trend.
//+------------------------------------------------------------------+
//| 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 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_level1 0.0003
#property indicator_level2 -0.0003
//---- indicator buffers
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
double ind_buffer1[];
double ind_buffer2[];
double ind_buffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 1 additional buffer used for counting.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
//---- 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);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev,current;
//---- 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_buffer3[i]=iOsMA(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_WEIGHTED,i);
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ind_buffer3[i];
prev=ind_buffer3[i+1];
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ind_buffer2[i]=current;
ind_buffer1[i]=0.0;
}
else
{
ind_buffer1[i]=current;
ind_buffer2[i]=0.0;
}
}
//---- done
return(0);
}
Comments