SSL_fastA
Download scriptThis script is a technical analysis tool designed for the MetaTrader platform to help traders identify and visualize market trends in real-time. It functions by tracking price movements and calculating a specific "trend" line based on the relationship between current prices and historical averages.
Core Functionality
The primary goal of this tool is to determine the prevailing direction of the market (upward or downward). It achieves this by analyzing the interaction between the closing price of a candle and moving averages derived from the highest and lowest points of previous price action.
How the Logic Works
The script operates using a multi-step process to filter out "market noise" and highlight clear trends:
- Trend Identification: The system constantly monitors the current market price. It compares the closing price against two different mathematical benchmarks: one based on the recent highs and one based on the recent lows.
- Dynamic Switching: Based on these comparisons, the tool assigns a status to the market. If the price breaks above a specific high-based average, it registers an upward trend; if it falls below a low-based average, it registers a downward trend.
- Visual Mapping: Once the trend is established, the tool draws a line on your chart. This line dynamically adjusts its position depending on whether the market is in an "up" or "down" state, providing a clear visual path for the trader to follow.
Alert System
Beyond just visual representation, the script includes an automated notification system. It is programmed to detect the exact moment the trend switches from upward to downward (or vice versa). When this transition occurs, the tool can trigger multiple types of notifications depending on your preferences:
- On-Screen Alerts: A pop-up message appearing directly on your trading platform.
- Email Notifications: Sending a summary of the trend change to your registered email address.
- Audio Signals: Playing a sound file to grab your attention immediately.
The script includes built-in logic to ensure these alerts only fire once per trend change, preventing repetitive notifications on every single price tick and ensuring you are only notified when a significant shift in market direction occurs.
//+------------------------------------------------------------------+
//| SSL fast.mq4 |
//| mladen |
//| |
//| initial SSL for metatrader developed by Kalenzo |
//+------------------------------------------------------------------+
#property copyright "www.forex-tsd.com"
#property link "www.forex-tsd.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 CornflowerBlue
//
//
//
//
//
extern int Lb = 10;
extern bool alertsOn = false;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;
//
//
//
//
//
double ssl[];
double Hlv[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int init()
{
IndicatorBuffers(2);
SetIndexBuffer(0,ssl); SetIndexDrawBegin(0,Lb+1);
SetIndexBuffer(1,Hlv);
return(0);
}
//
//
//
//
//
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//
//
//
//
//
for(i=limit;i>=0;i--)
{
Hlv[i] = Hlv[i+1];
if(Close[i]>iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1)) Hlv[i] = 1;
if(Close[i]<iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1)) Hlv[i] = -1;
if(Hlv[i] == -1)
ssl[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
else ssl[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1);
}
//
//
//
//
//
if (alertsOn)
if (Hlv[0] != Hlv[1])
if (Hlv[0] == 1)
doAlert("up");
else doAlert("down");
return(0);
}
//
//
//
//
//
void doAlert(string doWhat)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
//
//
//
//
//
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," SSL trend changed to ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol(),"SSL "),message);
if (alertsSound) PlaySound("alert2.wav");
}
}
Comments