Author: Kalenzo
wma_cross2

This script is designed as a technical analysis tool for the MetaTrader trading platform. It functions by monitoring price movement trends and generating visual signals on your chart to help identify potential entry and exit points for trades.

Core Logic Overview

The tool operates by calculating three different Moving Averages (MAs) simultaneously. These averages act as "smoothed" versions of the market price, helping to filter out minor market noise so that the underlying trend becomes clearer.

  1. Short-Term Average: Tracks fast-moving price action.
  2. Long-Term Average: Identifies the primary, overarching trend of the market.
  3. Exit Average: Acts as a secondary filter specifically used to determine when a trade's momentum is fading.

How it Identifies Signals

The script looks for specific "crossovers"—moments where these averages cross over one another—to trigger different types of alerts:

  • Buy Signals (Up): These appear when the fast-moving average moves above the long-term trend line while transitioning from a position below it. This suggests that upward momentum is beginning to take hold.
  • Sell Signals (Down): These occur when the fast-moving average drops below the long-term trend line, indicating that downward pressure is increasing.
  • Exit Signals: The script includes specialized logic to identify when a trade may be reaching its end. It compares the current price against the "Exit Average" and the "Long-Term Trend." If the price moves into a contradictory zone relative to these averages, it generates an exit signal to help you manage your position.

User Experience Features

To ensure the trader can react quickly, the script includes several automated notification features:

  • Visual Markers: It places specific arrows on the chart at the exact moment a signal is detected (above the high or below the low of the price candle).
  • Audio Alerts: You can enable a sound notification to alert you instantly when a new signal appears.
  • On-Screen Information: The tool can display a text comment directly on your chart, providing real-time data such as the current Buy/Sell prices, the exact date and time of the signal, and the specific symbol and timeframe being traded.

In summary, this tool serves as a trend-following assistant that simplifies complex price movements into clear visual cues, helping you identify when to enter a trade based on momentum and when it might be appropriate to step out.

Price Data Components
Series array that contains the lowest prices of each barSeries array that contains open time of each barSeries array that contains the highest prices of each barSeries array that contains close prices for each bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It plays sound alerts
15 Views
0 Downloads
0 Favorites
wma_cross2
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                          Kalenzo |
//|                                                  simone@konto.pl |
//|                                    Modified by Newdigital        |
//+------------------------------------------------------------------+

#property copyright "Kalenzo"
#property link      "simone@konto.pl"

#property indicator_chart_window
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 DeepPink
extern bool UseSound = True;
extern bool TypeChart = True;
extern string NameFileSound = "alert.wav";
extern int ShortPeriod = 5;
extern int ShortPeriodMode =  1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int BigPeriod = 50;
extern int BigPeriodMode =  1; //0=sma, 1=ema, 2=smma, 3=lwma
extern int ExitPeriod = 20;
extern int ExitPeriodMode =  1; //0=sma, 1=ema, 2=smma, 3=lwma

#property indicator_buffers 4
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];
double ExitLong[];
double ExitShort[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

  // IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW,EMPTY,1);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
   SetIndexStyle(2,DRAW_ARROW,EMPTY,1);
  SetIndexStyle(3,DRAW_ARROW,EMPTY,1);
  
   SetIndexBuffer(0,UpBuffer);
   SetIndexBuffer(1,DnBuffer);
   SetIndexBuffer(2,ExitLong);
   SetIndexBuffer(3,ExitShort);
  
   SetIndexArrow(0,233);
   SetIndexArrow(1,234);
   SetIndexArrow(2,251);
   SetIndexArrow(3,251);

   SetIndexLabel(0,"Up Signal");
   SetIndexLabel(1,"Down Signal");
   SetIndexLabel(2,"Exit Long");
   SetIndexLabel(3,"Exit Short");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
  
   for(int i = 0 ;i < limit ;i++)
   { 
      double pwma5 = iMA(Symbol(),0,ShortPeriod,0,ShortPeriodMode,PRICE_CLOSE,i+1);
      double cwma5 = iMA(Symbol(),0,ShortPeriod,0,ShortPeriodMode,PRICE_CLOSE,i);
      
      double pwma50 = iMA(Symbol(),0,BigPeriod,0,BigPeriodMode,PRICE_CLOSE,i+1);
      double cwma50 = iMA(Symbol(),0,BigPeriod,0,BigPeriodMode,PRICE_CLOSE,i);
      
      double pwma20 = iMA(Symbol(),0,ExitPeriod,0,ExitPeriodMode,PRICE_CLOSE,i+1);
      double cwma20 = iMA(Symbol(),0,ExitPeriod,0,ExitPeriodMode,PRICE_CLOSE,i);
       
      if( cwma5 > cwma50 && pwma5 <= pwma50)
      {  
        UpBuffer[i] = iLow(Symbol(),0,i)-(3*Point);
        DnBuffer[i] = EMPTY_VALUE;
      if (UseSound==1) PlaySound(NameFileSound);
      if (TypeChart==1) Comment ("Buy signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
      }
      
      else if( pwma5 >= pwma50 && cwma5 < cwma50)
      {
        UpBuffer[i] = EMPTY_VALUE;
        DnBuffer[i] = iHigh(Symbol(),0,i)+(3*Point);
      if (UseSound==1) PlaySound(NameFileSound);
      if (TypeChart==1) Comment ("Sell signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
      }
      else
      {
        DnBuffer[i] = EMPTY_VALUE;
        UpBuffer[i] = EMPTY_VALUE;
      }
      
      if( cwma5 > cwma20 && pwma5 <= pwma20 && iClose(Symbol(),0,i) < cwma50)
      {  
        ExitShort[i] = iHigh(Symbol(),0,i)+(3*Point);
        ExitLong[i] =  EMPTY_VALUE;
      }
      else if( pwma5 >= pwma20 && cwma5 < cwma20 && iClose(Symbol(),0,i) > cwma50)
      {
        ExitShort[i] = EMPTY_VALUE;
        ExitLong[i] = iLow(Symbol(),0,i)-(3*Point);
      }
      else
      {
        ExitShort[i] = EMPTY_VALUE;
        ExitLong[i] = EMPTY_VALUE;
      }
  
   }
//----

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



Comments