Ergodic Signals
Download scriptThis script is designed as a visual trading tool for the MetaTrader platform, specifically created to identify potential entry points by analyzing price momentum. Instead of drawing complex lines or curves that can clutter your screen, this tool simplifies market data into clear visual cues—arrows—that appear directly on your price chart.
Core Logic and Functionality
The script operates by monitoring the relationship between two different data streams derived from a specialized mathematical model known as the "Ergodic Oscillator." It constantly compares the main momentum of the market against a smoothed "signal" line to detect shifts in trend direction.
How it identifies signals:
- Buy Signals (Upward Arrows): The script looks for a specific "crossover" event. When the primary momentum value moves from below the signal line to above it, the script recognizes this as an upward shift in strength. It then places a red arrow on the chart at the price point to notify you of the potential move.
- Sell Signals (Downward Arrows): Conversely, if the primary momentum falls from above the signal line to below it, the script identifies a downward shift in strength. It responds by placing a blue arrow on the chart to highlight this potential reversal or bearish trend.
Key Customization Features
The tool includes several adjustable parameters that allow you to fine-tune how sensitive the arrows are to market movements:
- Period Settings: You can modify the primary and secondary periods (First_R, Second_S) and the Signal Period. Adjusting these determines how much historical data the script looks at; shorter periods make the tool more reactive to fast price changes, while longer periods filter out "noise" for a smoother, slower signal.
- Smoothing Mode: This allows you to control how much the data is averaged to prevent false signals during volatile market conditions.
- Visual Offset (Arrow Shift): This ensures that the arrows do not overlap directly with the price candles, keeping your chart clean and easy to read.
In summary, this script automates the tedious process of watching oscillators for crossovers, providing you with immediate visual alerts on your chart whenever the underlying momentum suggests a change in market direction.
//+------------------------------------------------------------------+
//| 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 curErgodic=0.0,prevErgodic=0.0,curSignal=0.0,prevSignal=0.0;
limit=Bars-counted_bars-First_R-Second_S-SignalPeriod;
for (i=limit;i>=0;i--)
{
curErgodic=iCustom(NULL,0,"Ergodic Oscillator",First_R,Second_S,SignalPeriod,Mode_Smooth,0,i);
prevErgodic=iCustom(NULL,0,"Ergodic Oscillator",First_R,Second_S,SignalPeriod,Mode_Smooth,0,i+1);
curSignal=iCustom(NULL,0,"Ergodic Oscillator",First_R,Second_S,SignalPeriod,Mode_Smooth,1,i);
prevSignal=iCustom(NULL,0,"Ergodic Oscillator",First_R,Second_S,SignalPeriod,Mode_Smooth,1,i+1);
if ((curErgodic>curSignal)&&(prevErgodic<prevSignal)) ExtMapBuffer1[i]=Close[i]+3*ArrowShift*Point;
if ((curErgodic<curSignal)&&(prevErgodic>prevSignal)) ExtMapBuffer2[i]=Close[i]-ArrowShift*Point;
}
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
Comments