TSI Signals_v1
Download scriptThis script is designed as a visual trading tool for the MetaTrader platform. Its primary purpose is to identify specific momentum shifts in the market and translate those movements into clear, easy-to-read visual signals directly on your price chart.
How the Logic Works
The script functions by analyzing two distinct data streams from a secondary technical indicator known as the TSI (Trade Signal Index). It doesn't just look at the price of an asset in isolation; instead, it evaluates the relationship between the primary momentum line and its corresponding signal line.
1. Data Gathering: The script constantly monitors two variables:
- The TSI Line: This represents the core momentum of the market.
- The Signal Line: This is a smoothed average of the momentum, used to filter out "noise" and identify the true direction of the trend.
2. The Crossing Logic: The tool identifies "crossovers," which are often used by traders to spot potential reversals or accelerations in price movement. It looks for two specific scenarios:
- Bullish Signal (Upward Movement): The script watches for the moment the primary TSI line crosses above the signal line. When this happens, it interprets the momentum as shifting toward the upside and places a visual marker (an arrow) on the chart.
- Bearish Signal (Downward Movement): Conversely, the script watches for the moment the primary TSI line drops below the signal line. This suggests a loss of upward momentum or a shift toward the downside, triggering a different visual marker on the chart.
Visual Presentation
Instead of forcing you to read complex numerical data or navigate through multiple sub-windows, the script does the heavy lifting for you. It automatically calculates these crossovers and places directional arrows directly on your main price candles.
- Upward Arrows: Appear when the momentum shifts positively.
- Downward Arrows: Appear when the momentum shifts negatively.
Key Customizations
The logic is built to be flexible, allowing for adjustments in how "sensitive" the tool is to market changes. You can modify the period lengths (how much historical data the script considers) and the smoothing mode. These settings allow you to fine-tune the tool to match different trading styles, whether you prefer to catch quick, fast-moving price swings or broader, more established trend shifts.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| TSI Signals.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 MediumBlue
//---- input parameters
extern int First_R=8;
extern int Second_S=5;
extern int SignalPeriod=5;
extern int Mode_Smooth=1;
extern int ArrowShift=5;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,217);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"UpArrow");
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,218);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,"DownArrow");
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,i;
double curTSI=0.0,prevTSI=0.0,curSignal=0.0,prevSignal=0.0;
limit=Bars-counted_bars-First_R-Second_S-SignalPeriod;
for (i=limit;i>=0;i--)
{
curTSI=iCustom(NULL,0,"TSI-Osc",First_R,Second_S,SignalPeriod,Mode_Smooth,0,i);
prevTSI=iCustom(NULL,0,"TSI-Osc",First_R,Second_S,SignalPeriod,Mode_Smooth,0,i+1);
curSignal=iCustom(NULL,0,"TSI-Osc",First_R,Second_S,SignalPeriod,Mode_Smooth,1,i);
prevSignal=iCustom(NULL,0,"TSI-Osc",First_R,Second_S,SignalPeriod,Mode_Smooth,1,i+1);
if ((curTSI>curSignal)&&(prevTSI<prevSignal)) ExtMapBuffer1[i]=Close[i]+3*ArrowShift*Point;
if ((curTSI<curSignal)&&(prevTSI>prevSignal)) ExtMapBuffer2[i]=Close[i]-ArrowShift*Point;
}
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
Comments