Author: Copyright � 2008, MetaQuotes Software Corp.
_Fast2

This script is a custom technical analysis indicator designed to help traders identify potential entry points for "Buy" and "Sell" positions by analyzing price momentum and moving average trends. It functions by processing historical price data into a simplified visual and mathematical model on your trading chart.

Core Logic Overview

The tool works through three primary stages of calculation:

1. Data Normalization (Momentum Calculation) Instead of looking at raw prices alone, the script first calculates a custom momentum value. It looks at the difference between the opening and closing prices over the last three bars. By applying a specific mathematical weight to these differences, it creates a "smoothed" representation of price movement. This helps filter out minor market noise and focuses on the underlying trend.

2. Trend Smoothing (Moving Averages) The script then applies two different types of Weighted Moving Averages (LWMA) to that momentum data. Think of this as taking the "momentum" calculated in the first step and smoothing it out even further into two separate lines:

  • A Fast Line (based on a short period, e.g., 3 bars).
  • A Slow Line (based on a longer period, e.g., 9 bars).

By comparing these two lines against each other, the script can identify "crossovers"—moments where the short-term momentum shifts direction relative to the long-term trend.

3. Signal Generation and Alerts The indicator looks for specific "confluence" patterns where multiple conditions must be met simultaneously before triggering a signal:

  • Sell Signals: Triggered when the Fast Line crosses below the Slow Line while the price momentum is also trending downward. When this occurs, the script can trigger an audio alert, a visual notification on your screen, and a text comment displaying a suggested "Stop Loss" level based on the current volatility.
  • Buy Signals: Triggered when the Fast Line crosses above the Slow Line while the price momentum is trending upward. Similar to the sell signal, this provides a visual arrow and data for a potential "Buy" entry.
  • Exit/Closing Signals: The script also monitors the "gap" between the Fast and Slow lines. If the distance between these two lines begins to shrink significantly, it generates a "Close !!!" notification. This suggests that the momentum is losing strength and it may be an appropriate time to exit an open trade.

User Experience Features

  • Automated Alerts: The script can be configured to play sounds (alert.wav / alert2.wav) or pop up alerts on your screen so you don't have to watch the charts constantly.
  • On-Screen Comments: It provides real-time text updates on your chart showing current trade recommendations and calculated risk levels (Stop Loss).
  • Smart Scaling: The script automatically detects specific major currency pairs (like EURUSD, GBPUSD, etc.) to ensure the calculations remain consistent across different markets.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It plays sound alerts
12 Views
0 Downloads
0 Favorites
_Fast2
//+------------------------------------------------------------------+
//|                                                       _Fast2.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 LightSeaGreen
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_color5 Red
#property indicator_color6 Blue
extern int    ma1=3;
extern int    ma2=9;
extern bool   sound=true;
extern bool   alert=false;
extern bool   comment=true;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double Outbuf[];
static int prevtime = 0 ;        // Âðåìÿ ïîñëåäíåãî áàðà
double spr,stop;
string simv;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,0,2);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE,0,2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexBuffer(3,Outbuf);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,236);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexArrow(5,238);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexEmptyValue(5,0.0);
//----
Outbuf[1]=0;
simv = (Symbol());
  if (simv == "EURUSD") 
     {
     spr = MarketInfo("EURUSD",MODE_SPREAD); 
     stop = MarketInfo("EURUSD",MODE_STOPLEVEL);
     }
  if (simv == "GBPUSD") 
     {
     spr = MarketInfo("GBPUSD",MODE_SPREAD); 
     stop = MarketInfo("GBPUSD",MODE_STOPLEVEL);
     }
  if (simv == "EURJPY") 
     {
     spr = MarketInfo("EURJPY",MODE_SPREAD); 
     stop = MarketInfo("EURJPY",MODE_STOPLEVEL);
     }
  if (simv == "GBPJPY") 
     {
     spr = MarketInfo("GBPJPY",MODE_SPREAD); 
     stop = MarketInfo("GBPJPY",MODE_STOPLEVEL);
     }
  if (simv == "USDJPY") 
     {
     spr = MarketInfo("USDJPY",MODE_SPREAD); 
     stop = MarketInfo("USDJPY",MODE_STOPLEVEL);
     }
  if (simv == "EURCHF") 
     {
     spr = MarketInfo("EURCHF",MODE_SPREAD); 
     stop = MarketInfo("EURCHF",MODE_STOPLEVEL);
     }
  if (simv == "GBPCHF") 
     {
     spr = MarketInfo("GBPCHF",MODE_SPREAD); 
     stop = MarketInfo("GBPCHF",MODE_STOPLEVEL);
     }
  if (simv == "USDCHF") 
     {
     spr = MarketInfo("USDCHF",MODE_SPREAD); 
     stop = MarketInfo("USDCHF",MODE_STOPLEVEL);
     }
  if (simv == "USDCAD") 
     {
     spr = MarketInfo("USDCAD",MODE_SPREAD); 
     stop = MarketInfo("USDCAD",MODE_STOPLEVEL);
     }
  if (simv == "AUDUSD") 
     {
     spr = MarketInfo("AUDUSD",MODE_SPREAD); 
     stop = MarketInfo("AUDUSD",MODE_STOPLEVEL);
     } 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
Comment("  ");    
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
int    counted_bars=IndicatorCounted();
//----
   if(counted_bars>0)
        counted_bars--;
     
   int limit=Bars-counted_bars;
   for(int i=0;i<Bars;i++)
   {
   ExtMapBuffer1[i]=((Close[i]-Open[i])+((Close[i+1]-Open[i+1])/MathSqrt(2))+((Close[i+2]-Open[i+2])/MathSqrt(3)))/Point;
  // ExtMapBuffer1[i]=((Close[i]-Open[i])+((Close[i+1]-Open[i+1])/MathSqrt(2))+((Close[i+2]-Open[i+2])/MathSqrt(3))+((Close[i+3]-Open[i+3])/MathSqrt(5))+((Close[i+4]-Open[i+4])/MathSqrt(8)))/Point;

   }
   for(i=0;i<Bars;i++)
   {
   ExtMapBuffer2[i]=iMAOnArray(ExtMapBuffer1,Bars,ma1,0,MODE_LWMA,i);
   ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer1,Bars,ma2,0,MODE_LWMA,i);
   }
// Æäåì, êîãäà ñôîðìèðóåòñÿ íîâûé áàð
   if (Time[0] == prevtime) return(0);
   prevtime = Time[0];
   Outbuf[1]=0;  
//--------------------   
      if (((ExtMapBuffer2[2] > ExtMapBuffer3[2])&&(ExtMapBuffer2[1] < ExtMapBuffer3[1])&&(ExtMapBuffer2[0] < ExtMapBuffer3[0]))
             &&((ExtMapBuffer2[2]>0)&&(ExtMapBuffer3[2]>0))&&((ExtMapBuffer1[1]<=0)&&(ExtMapBuffer1[0]<0)))
             {
             ExtMapBuffer6[1]=(ExtMapBuffer1[1]+ExtMapBuffer2[1]); 
         if (sound==true)PlaySound("alert.wav");             
         if (alert==true) Alert (Symbol());  
         if (comment==true)Comment(Symbol(),TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n","SELL    SL= ",MathAbs(ExtMapBuffer1[1]-Close[1]));
             Outbuf[1]=1;
             Outbuf[2]=(MathAbs(ExtMapBuffer1[1]-Close[1]));
             if (Outbuf[2]<stop) Outbuf[2] =(MathAbs(ExtMapBuffer1[1]-Close[1]))+ stop;
             } else { ExtMapBuffer6[1]= 0.0; }
      if (((ExtMapBuffer2[2] < ExtMapBuffer3[2])&&(ExtMapBuffer2[1] > ExtMapBuffer3[1])&&(ExtMapBuffer2[0] > ExtMapBuffer3[0]))
             &&((ExtMapBuffer2[2]<0)&&(ExtMapBuffer3[2]<0))&&((ExtMapBuffer1[1]>=0)&&(ExtMapBuffer1[0]>0)))
             {
             ExtMapBuffer5[1]=(ExtMapBuffer1[1]+ExtMapBuffer2[1]);
         if (sound==true)PlaySound("alert.wav");             
         if (alert==true) Alert (Symbol()); 
         if (comment==true)Comment(Symbol(),TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n","BUY     SL= ",MathAbs(ExtMapBuffer1[1]-Close[1]));
             Outbuf[1]=2;
             Outbuf[2]=(MathAbs(ExtMapBuffer1[1]-Close[1]));
             if (Outbuf[2]<stop) Outbuf[2]=(MathAbs(ExtMapBuffer1[1]-Close[1]))+ stop;
             } else {  ExtMapBuffer5[1]= 0.0;  }    

   if ((ExtMapBuffer2[2] - ExtMapBuffer3[2]) > (ExtMapBuffer2[1] - ExtMapBuffer3[1]))
         {
         if (sound==true)PlaySound("alert2.wav");
         if (comment==true)Comment(TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n","Close !!!",(Close[1]));
          Outbuf[1]=3;
         }

   
   
   
   
      
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments