Author: Kalenzo
wma_cross6

This tool is a visual trading indicator designed to help identify potential entry points in the market by monitoring price trends. It works by comparing two different types of moving averages—essentially "fast" and "slow" trend lines—to determine when momentum is shifting in favor of a purchase (Buy) or a sale (Sell).

How the Logic Works

The script continuously calculates two sets of moving averages based on periods you define:

  1. Short-Term Trend: A faster-moving average that reacts quickly to recent price changes.
  2. Long-Term Trend: A slower-moving average that represents the broader market direction.

By comparing where these two lines sit in relation to one another, the script identifies specific "crossover" moments:

  • Buy Signals: The indicator looks for a specific scenario where the short-term trend is positioned above the long-term trend, but it detects a moment where the previous bar's short-term line was at or below the long-term line. When this crossover occurs, it places a visual arrow on your chart to signal a potential upward move.
  • Sell Signals: Conversely, the indicator looks for a scenario where the short-term trend has dropped below the long-term trend, specifically when the previous bar's short-term line was at or above the long-term line. This triggers a visual arrow to signal a potential downward move.

Key Features and Customization

The logic is designed to be flexible, allowing you to tailor the sensitivity of the signals through several settings:

  • Trend Sensitivity: You can adjust the "Periods" to make the indicator more or less sensitive. Shorter periods will react faster to price spikes, while longer periods will filter out smaller fluctuations to focus on major trends.
  • Moving Average Types: The tool allows you to choose different calculation methods (such as Simple, Exponential, etc.), which changes how "smoothly" the trend lines flow.
  • Price Buffers: You can include a small numerical "Delta" to add a required gap between the lines before a signal is triggered, helping to filter out "noisy" markets where the lines are touching but not clearly crossing.
  • Notifications: Beyond visual arrows on the chart, the script can be configured to provide real-time feedback via:
    • Audible Alerts: Playing a sound file when a crossover occurs.
    • Pop-up Alerts: Sending a text notification window with the symbol name and time.
    • On-Screen Comments: Printing a detailed summary of the current Buy or Sell signal, including the specific prices (Ask/Bid) and the exact time on your trading screen.
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 bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It plays sound alerts
11 Views
0 Downloads
0 Favorites
wma_cross6
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                          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

extern bool UseSound = False;
extern bool TypeChart = False;
extern bool UseAlert = False;
extern string NameFileSound = "alert.wav";
extern double ShortPeriod = 6;
extern int ShortPeriodMode =  1; //0=sma, 1=ema, 2=smma, 3=lwma
extern double BigPeriod = 21;
extern int BigPeriodMode =  0; //0=sma, 1=ema, 2=smma, 3=lwma
extern int DeltaForSell = 0;
extern int DeltaForBuy = 0;

#property indicator_buffers 2
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

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

   SetIndexLabel(0,"Up Signal");
   SetIndexLabel(1,"Down Signal");

//----
   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);
            
      if( cwma5 > (cwma50 +(DeltaForBuy*Point)) && pwma5 <= pwma50)
      {  
        UpBuffer[i] = iLow(Symbol(),0,i)-(3*Point);
        DnBuffer[i] = EMPTY_VALUE;
      if (UseSound==1) PlaySound(NameFileSound);
      if (UseAlert==1) Alert(Symbol(), "Buy signal", Period());
      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 - (DeltaForSell*Point)))
      {
        UpBuffer[i] = EMPTY_VALUE;
        DnBuffer[i] = iHigh(Symbol(),0,i)+(3*Point);
      if (UseSound==1) PlaySound(NameFileSound);
      if (UseAlert==1) Alert(Symbol(), "Sell signal", Period()); 
      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;
      }
      
      
  
   }
//----

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



Comments