This tool is designed as a visual technical indicator for the MetaTrader platform, specifically created to help traders identify potential buying and selling opportunities by monitoring momentum shifts in the market.
How it Works
The logic relies on a mathematical calculation known as the Commodity Channel Index (CCI). The CCI measures how far the current price of an asset is moving away from its average price over a specific period. By tracking these fluctuations, the script identifies "overextended" movements that often precede a reversal in trend.
Key Features and Logic
- Momentum Tracking: The script constantly compares the current momentum value against the previous one. It looks for specific "crossover" points where the momentum moves from a significant negative state to a positive one (or vice versa).
- Visual Signals:
- Buy Signals: When the indicator detects that the momentum has surged upward from a deeply negative position, it places a Blue arrow below the price candle.
- Sell Signals: When the indicator detects that the momentum has dropped significantly from a high positive position, it places a Red arrow above the price candle.
- Dynamic Positioning: To ensure the visual arrows do not overlap with the actual price candles, the script automatically adjusts the distance of the arrows based on the timeframe you are using (e.g., 1-minute charts vs. Daily charts).
- Automated Alerts: The script features a notification system that can send real-time alerts to your platform. It is programmed to announce "Buy" or "Sell" signals as they occur, providing you with immediate notification of potential entry points.
- Signal Filtering: To prevent "noise" and unnecessary notifications, the script includes a logic gate that limits the frequency of alerts, ensuring you are notified of the most relevant moves rather than every minor fluctuation.
Summary for Traders
Essentially, this tool acts as a momentum detector. It scans the market history to find moments where the price is "stretched" too far in one direction and signals when it is likely to snap back. The resulting Blue and Red arrows serve as visual cues to help you spot these transition points quickly on your chart.
//+------------------------------------------------------------------+
//| Sig_Soch.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int PerCCI=24;
extern bool Al=true;
double CCI;
double CCIold;
double ArrShift;
double BufUp[];
double BufDn[];
int s,b;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0, BufUp);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 233);
SetIndexBuffer(1, BufDn);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 234);
switch (Period()) {
case PERIOD_M1: ArrShift = Point * 5; break;
case PERIOD_M5: ArrShift = Point * 10; break;
case PERIOD_M15: ArrShift = Point * 20; break;
case PERIOD_M30: ArrShift = Point * 20; break;
case PERIOD_H1: ArrShift = Point * 40; break;
case PERIOD_H4: ArrShift = Point * 80; break;
case PERIOD_D1: ArrShift = Point * 100; break;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,
Counted_bars=IndicatorCounted();
i=Bars-Counted_bars-1;
//----
while(i>=1) // Öèêë ïî íåïîñ÷èòàííûì áàðàì
{
CCI=iCCI(NULL,0,PerCCI,PRICE_TYPICAL,i);
CCIold=iCCI(NULL,0,PerCCI,PRICE_TYPICAL,i+1);
if (CCI>-100 && CCIold<-100) {BufUp[i]=Low[i] - ArrShift;if (b<2 && Al==true) {Alert(Symbol()+" CCI Ãîâîðèò ïîêóïàé ïî "+Close[i]);b=b+1;s=0;}}
if (CCI<100 && CCIold>100) {BufDn[i]=High[i] + ArrShift;if (s<2 && Al==true) {Alert(Symbol()+" CCI Ãîâîðèò ïðîäàâàé ïî "+Close[i]);s=s+1;b=0;}}
i--; // Ðàñ÷¸ò èíäåêñà ñëåäóþùåãî áàðà
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments