0-0-TANGO
Download scriptThis technical indicator is designed to analyze market momentum and price action by identifying specific patterns in the relationship between Relative Strength Index (RSI) values and actual closing prices. Its primary goal is to provide visual signals on a trading chart to help identify potential trend reversals or directional shifts.
Core Logic Overview
The script functions by scanning back through historical data to compare current market conditions against a defined window of past performance. It specifically looks for "divergences"—situations where the price movement and the momentum indicator (RSI) are moving in opposite directions.
How the Analysis Works:
- Historical Scanning: The tool examines a specific range of previous candles (defined by the user settings) to establish a high and low range of momentum.
- Divergence Detection: It looks for instances where the price has moved higher while the momentum is falling, or where the price has dropped while the momentum is rising. This type of discrepancy often suggests that the current trend is losing steam.
- Threshold Filtering: To ensure the signals are meaningful and not just minor market noise, the script applies a "Porog" (threshold) calculation. It defines specific boundaries based on the spread between the highest and lowest momentum points found during its scan.
- Signal Categorization: Based on where the momentum falls within these boundaries relative to the price action, the indicator classifies the market into three distinct outcomes:
- Bullish Signal: Triggered when momentum is sufficiently strong relative to the established range despite opposing price action. This is marked visually on the chart.
- Bearish Signal: Triggered when momentum falls below a specific lower threshold, suggesting a potential downward move. This is also marked visually on the chart.
- Neutral State: If the momentum falls within a "middle ground" or fails to meet the specific criteria for a reversal, the indicator remains neutral and provides no signal.
Visual Output
The logic translates these complex calculations into simple visual markers directly on your trading candles:
- Yellow Indicators: Represent identified upward/bullish signals.
- Blue Indicators: Represent identified downward/bearish signals.
- Red Indicators: Represent neutral market conditions where no clear divergence or threshold breach was detected.
//+------------------------------------------------------------------+
//| 0-0-TANGO.mq4 |
//| Copyright © 2009, MetaQL. |
//| mrexpertforex@mail.ru |
//+------------------------------------------------------------------+
#property copyright "MetaQL"
#property link "mrexpertforex@mail.ru"
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Red
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern int X=20;
extern double POROG=20;
extern int GJIYBUHA=100;
extern int COUNTED_BARS=1000;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double buf_1[];
double buf_2[];
double buf_3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,buf_1);
SetIndexStyle(0,DRAW_ARROW,0,2);
SetIndexArrow(0,233);
SetIndexBuffer(1,buf_2);
SetIndexStyle(1,DRAW_ARROW,0,2);
SetIndexArrow(1,234);
SetIndexBuffer(2,buf_3);
SetIndexStyle(2,DRAW_ARROW,0,2);
SetIndexArrow(2,111);
//----
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit=0;
if(counted_bars>0)counted_bars--;
limit=Bars-counted_bars;
if(limit>COUNTED_BARS)
limit=COUNTED_BARS;
for(int i=1;i<=limit;i++)
{
//++++++++++++++++++++++
int rezult=0;
//--
double HI_RSI=iRSI(NULL,0,X,0,i);
double LO_RSI=iRSI(NULL,0,X,0,i);
//--
int HI_RSI_b=i;
int LO_RSI_b=i;
//--
double RSI_1=iRSI(NULL,0,X,0,i);
//--
for(int b1=i+1;b1<=i+GJIYBUHA;b1++)
{
//++++++++++++++++++++++++++++++
double RSI_2=iRSI(NULL,0,X,0,b1);
//--
if(RSI_2>HI_RSI)
{
HI_RSI=RSI_2;
HI_RSI_b=b1;
}
//---
if(RSI_2<LO_RSI)
{
LO_RSI=RSI_2;
LO_RSI_b=b1;
}
//---
if( (Close[b1]<Close[i] && RSI_2>=RSI_1)||(Close[b1]>=Close[i] && RSI_2<RSI_1) )
{
//--
double UP=HI_RSI-((HI_RSI-LO_RSI)/100)*POROG;
//--
if(RSI_2>=UP)
{
rezult=1;
}
//---
double DOWN=LO_RSI+((HI_RSI-LO_RSI)/100)*POROG;
//--
if(RSI_2<=DOWN)
{
rezult=-1;
}
//--
if( RSI_2>DOWN && RSI_2<UP )
{
rezult=0;
}
//---
break;
}
//++++++++++++++++++++++++++++++
}
//---
if(rezult>0)
{
buf_1[i]=Low[i];
buf_2[i]=EMPTY_VALUE;
buf_3[i]=EMPTY_VALUE;
}
//---
if(rezult<0)
{
buf_1[i]=EMPTY_VALUE;
buf_2[i]=High[i];
buf_3[i]=EMPTY_VALUE;
}
//---
if(rezult==0)
{
buf_1[i]=EMPTY_VALUE;
buf_2[i]=EMPTY_VALUE;
buf_3[i]=Close[i];
}
//---
//++++++++++++++++++++++
}
//----
}
Comments