VAZ2107U
Download scriptThe KAS721G Indicator is a technical analysis tool designed for the MetaTrader platform to identify specific trend-reversal opportunities by filtering price action through three distinct layers of logic. Rather than relying on a single price movement, it looks for a "confluence" of signals—meaning it only triggers an alert when multiple mathematical conditions align simultaneously.
Core Logic Components
The script evaluates three primary components to determine its signals:
- Moving Average Crossovers: The indicator tracks two different Simple Moving Averages (SMA) representing short-term and medium-term price momentum (7 periods and 21 periods). It specifically watches for "crossovers," where the faster average crosses over the slower one, indicating a potential shift in the immediate trend.
- Gann HiLo Activator: This acts as a trend filter. The script monitors the direction of this activator to ensure that the price momentum is moving in the desired direction before confirming a signal.
- Price Position Validation: To prevent "false positives" where the market might be volatile but not trending, the script checks the current opening price against the Activator's position.
Signal Generation
The indicator produces two types of visual signals (arrows) and notifications:
-
Long Opportunities (Buy): A "Go Long" signal is triggered only if three things happen at once:
- The short-term moving average crosses above the medium-term moving average.
- The Gann HiLo Activator is trending upward.
- The current opening price is positioned above the Activator.
-
Short Opportunities (Sell): A "Go Short" signal is triggered only if these three conditions align:
- The short-term moving average crosses below the medium-term moving average.
- The Gann HiLo Activator is trending downward.
- The current opening price is positioned below the Activator.
User Experience and Notifications
When the logic identifies a valid entry point, the script performs three actions simultaneously to alert the trader:
- Visual Cues: It places a blue arrow below the candle for long positions and a red arrow above the candle for short positions.
- Audio Alerts: It plays a specific sound file to notify the user of the live movement.
- Email & Logs: It sends an email notification and prints a message in the system log, ensuring the trader is aware of the signal even if they are not looking at the screen.
The script includes a "smart" notification filter that ensures you are only alerted once per new price bar, preventing the system from sending repetitive notifications for the same movement.
//+------------------------------------------------------------------+
//| KAS721G Indicator v0.1 |
//| Copyright © 2008, Erik Dahlstrand |
//| http://www.dahlstrand.eu/ |
//| |
//| Indicator based on "KAS721G" by caireono |
//| http://forums.babypips.com/free-forex-trading-systems/ |
//| 11793-kas721g-trading-system.html |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Erik Dahlstrand"
#property link "http://www.dahlstrand.eu/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double validEntryLongBuffer[];
double validEntryShortBuffer[];
//---- input parameters
extern int entryArrowDisplacement = 6;
int init()
{
SetIndexArrow(0, SYMBOL_ARROWUP);
SetIndexBuffer(0, validEntryLongBuffer);
SetIndexEmptyValue(0, 0.0);
SetIndexLabel(0, "Go long");
SetIndexStyle(0, DRAW_ARROW, EMPTY, 3, Blue);
SetIndexArrow(1, SYMBOL_ARROWDOWN);
SetIndexBuffer(1, validEntryShortBuffer);
SetIndexEmptyValue(1, 0.0);
SetIndexLabel(1, "Go short");
SetIndexStyle(1, DRAW_ARROW, EMPTY, 3, Red);
Comment("KAS721G Indicator");
IndicatorShortName("KAS721G Indicator");
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int countedBars = IndicatorCounted();
int limit;
bool isMaCrossUp, isMaCrossDown;
double currentOpenPrice;
//---- indicators
double currentMA7, previousMA7; // Simple Moving Average (7)
double currentMA21, previousMA21; // Simple Moving Average (21)
double currentGHLA, previousGHLA; // Gann HiLo Activator
if(countedBars < 0) return(-1);
if(countedBars > 0) countedBars--;
limit = Bars - countedBars;
for(int i = 0; i < limit; i++)
{
currentMA7 = iMA(NULL, 0 , 7, 0, MODE_SMA, PRICE_CLOSE, i);
previousMA7 = iMA(NULL, 0 , 7, 0, MODE_SMA, PRICE_CLOSE, i + 1);
currentMA21 = iMA(NULL, 0 , 21, 0, MODE_SMA, PRICE_CLOSE, i);
previousMA21 = iMA(NULL, 0 , 21, 0, MODE_SMA, PRICE_CLOSE, i + 1);
currentGHLA = iCustom(NULL, 0, "Gann HiLo Activator", 2, i);
previousGHLA = iCustom(NULL, 0, "Gann HiLo Activator", 2, i + 1);
currentOpenPrice = Open[i];
isMaCrossUp = IsMaCrossUp(currentMA7, currentMA21, previousMA7, previousMA21);
isMaCrossDown = IsMaCrossDown(currentMA7, currentMA21, previousMA7, previousMA21);
if(isMaCrossUp && (currentGHLA > previousGHLA) && (currentGHLA < currentOpenPrice)) // I.e. upp trend
{
validEntryLongBuffer[i] = Low[i] - entryArrowDisplacement * Point;
if (i == 0) // Only notify on current bar
NotifyOnce("KAS721G indicator: GO LONG", "");
}
else if(isMaCrossDown && (currentGHLA < previousGHLA) && (currentGHLA > currentOpenPrice)) // I.e. down trend
{
validEntryShortBuffer[i] = High[i] + entryArrowDisplacement * Point;
if (i == 0) // Only notify on current bar
NotifyOnce("KAS721G indicator: GO SHORT", "");
}
}
return(0);
}
void NotifyOnce(string subject, string message)
{
static bool notified;
if (IsNewBar())
notified = false;
if (!notified)
{
SendMail(subject, message);
PlaySound("email.wav");
Print(subject);
notified = true;
}
}
bool IsMaCrossDown(double currentMA7, double currentMA21, double previousMA7, double previousMA21)
{
if ((currentMA7 < currentMA21) && (previousMA7 > previousMA21)) return (true);
return (false);
}
bool IsMaCrossUp(double currentMA7, double currentMA21, double previousMA7, double previousMA21)
{
if ((currentMA7 > currentMA21) && (previousMA7 < previousMA21)) return (true);
return (false);
}
bool IsNewBar()
{
static datetime previousDateTime;
datetime currentDateTime = Time[0];
if(previousDateTime != currentDateTime)
{
previousDateTime = currentDateTime;
return (true);
}
else
{
return (false);
}
}
Comments