OSMA_v3
Download scriptThis tool is designed to analyze price movements and provide visual signals on a trading chart to help identify potential buying and selling opportunities. It works by processing historical price data to detect shifts in market momentum.
Core Logic Overview
The script utilizes a specialized moving average calculation (OsMA) to determine the current trend of the market. Rather than just looking at the price, it evaluates how quickly and in what direction the price is moving relative to its recent history. It uses three primary timeframes (fast, slow, and signal periods) to smooth out market "noise" and focus on meaningful trends.
Visual Representation
The indicator displays two distinct histograms in a separate window below your main chart:
- Lime Highlights: These appear when the momentum is moving upward, suggesting a bullish trend.
- Red Highlights: These appear when the momentum is moving downward, suggesting a bearish trend.
By looking at these bars, a trader can visually see the "strength" of the current movement. If the bars are growing, the trend is accelerating; if they are shrinking or changing color, the trend may be losing steam.
Automated Alerts
Beyond the visual charts, the script features an intelligent alert system that monitors for specific "reversal" patterns in the data. It specifically looks for points where the momentum changes direction sharply:
- Buy Signals: The script identifies a potential "Buy" opportunity when it detects a "V-shaped" recovery in the momentum values (where the trend dips and then immediately turns upward).
- Sell Signals: The script identifies a potential "Sell" opportunity when it detects an "inverted V-shape" (where the trend peaks and then immediately turns downward).
When these specific conditions are met, the system will trigger an instant pop-up alert on your screen, providing you with the current price at that exact moment. This allows traders to react quickly to potential trend shifts without having to constantly watch every tick of the market.
//+------------------------------------------------------------------+
//| OSMA.mq4 |
//| 9 íîÿáðÿ 2008ã. Yuriy Tokman |
//| ICQ#:481-971-287 yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link "yuriytokman@gmail.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
extern int fast_ema_period =12;
extern int slow_ema_period = 26;
extern int signal_period = 9;
extern int applied_price = 0;
extern int barsToProcess =200;
extern bool wav = true;
double Buf0[];
double Buf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,Buf0);
SetIndexBuffer(1,Buf1);
SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),
//----
limit;
int i=0;
if(counted_bars>0)counted_bars--;
limit=Bars-counted_bars;
if(limit>barsToProcess)limit=barsToProcess;
while (i<limit)
{
double x0 = iOsMA(NULL,60,fast_ema_period,slow_ema_period,signal_period,applied_price,i) ;
double x1 = iOsMA(NULL,60,fast_ema_period,slow_ema_period,signal_period,applied_price,i+1) ;
double x2 = iOsMA(NULL,60,fast_ema_period,slow_ema_period,signal_period,applied_price,i+2) ;
if (x0>x1)Buf0[i]=x0;else Buf0[i]=0;
if (x0<x1)Buf1[i]=x0;else Buf1[i]=0;
if (wav==true)
{
if ( x2>x1 && x1<x0){Alert("Probably Buy\n\" Indicators to order e-mail: yuriytokman@gmail.com \"\nprice= ", Open[i]);}
if ( x2<x1 && x1>x0){Alert("Probably Sell\n\" Indicators to order ISQ#:481-971-287 \"\nprice= ", Open[i]);}
}
i++;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Comments