MA_TSI
Download scriptThis script is a custom technical analysis tool designed to identify specific trend reversal points or momentum shifts on a trading chart. It achieves this by combining three distinct types of data: moving averages, price action extremes, and an external oscillator.
How the Logic Works
The tool scans historical price data to look for moments where multiple mathematical conditions align simultaneously. It uses a "filtering" approach, meaning it only generates a signal when all the following criteria are met at once:
1. Moving Average Alignment The script tracks two sets of "fast" and "slow" moving averages. Instead of looking at just the middle price, it analyzes both the high and low points of the candles. It looks for a clear structural shift:
- For a downward signal, the fast moving averages must be positioned below the slow moving averages.
- For an upward signal, the fast moving averages must be positioned above the slow moving averages.
2. Momentum Crossings (The Oscillator) The script pulls data from an external indicator called "TSI-Osc." It looks for specific "crosses" where the momentum shifts from one side of a threshold to another. Specifically, it monitors whether the momentum moves from above to below (or vice versa) at three key levels:
- The center line (0.00)
- The upper boundary (+50.00)
- The lower boundary (-50.00)
3. Signal Generation When the script detects that the moving averages are aligned with a momentum crossing, it places a visual arrow on your chart:
- Bearish Signals (Down): If the price structure is weakening and momentum crosses downward at any of the three levels, a coral-colored arrow appears above the high of the candle.
- Bullish Signals (Up): If the price structure is strengthening and momentum crosses upward at any of the three levels, a white arrow appears below the low of the candle.
Summary for the Trader
Essentially, this tool acts as a confirmation system. It ignores minor price fluctuations and only triggers a signal when there is a synchronized agreement between the overall trend (Moving Averages) and the immediate speed of the price movement (TSI Oscillator). The result is a visual alert that helps highlight potential turning points in the market.
//+-------------------------------------------------------------------------+
//|MA_TSI.mq4 |
//|http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/ |
//+-------------------------------------------------------------------------+
#property copyright "http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/"
#property link "http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Coral
#property indicator_color2 White
//---- input parameters
extern int FastMAPeriod=6;
extern int SlowMAPeriod=18;
extern int First_R=4;
extern int Second_S=4;
extern int SignalPeriod=4;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,234);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,233);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
//----
for (i=Bars-50; i>=0; i--)
{
double ask = (MathRound(Ask/Point))*Point;
double bid = (MathRound(Bid/Point))*Point;
double spread = (ask-bid);
double one = iMA(Symbol(),0,FastMAPeriod,0,MODE_EMA,PRICE_HIGH,i);
double two = iMA(Symbol(),0,FastMAPeriod,0,MODE_EMA,PRICE_LOW,i);
double three = iMA(Symbol(),0,SlowMAPeriod,0,MODE_EMA,PRICE_HIGH,i);
double four = iMA(Symbol(),0,SlowMAPeriod,0,MODE_EMA,PRICE_LOW,i);
double LBB0 = iCustom(Symbol(),0,"TSI-Osc",First_R,Second_S,SignalPeriod,1,0,i);
double LBB1 = iCustom(Symbol(),0,"TSI-Osc",First_R,Second_S,SignalPeriod,1,0,i+1);
if (
((one < three) && (two < four)) &&
((LBB1 > 50.0000 && LBB0 < 50.0000) ||
(LBB1 > 0.0000 && LBB0 < 0.0000) ||
(LBB1 > -50.0000 && LBB0 < -50.0000))
)
ExtMapBuffer1[i]=High[i]+(spread*2);
if (
((one > three) && (two > four)) &&
((LBB1 < -50.0000 && LBB0 > -50.0000) ||
(LBB1 < -0.0000 && LBB0 > -0.0000) ||
(LBB1 < 50.0000 && LBB0 > 50.0000))
)
ExtMapBuffer2[i]=Low[i]-(spread*2);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments