wma_cross_confirm

Download script
Author: Kalenzo
wma_cross_confirm

This trading indicator is designed to provide visual cues on your charts to help identify potential entry points and strategic exit moments based on the relationship between different moving averages. It focuses on identifying momentum shifts and trend changes by comparing fast-moving price trends against slower, broader market cycles.

Core Logic and Signals

The tool operates using three distinct periods of weighted moving averages (Short, Big, and Exit). By analyzing how these averages cross one another over time, the script generates four specific types of signals:

1. Buy Signals (Up Signal) The indicator looks for a "bullish crossover." This occurs when the short-term trend moves above the long-term trend. Specifically, if the current short-term average is higher than the long-term one, but the previous candle's short-term average was below it, a Buy Signal is triggered. This suggests that upward momentum is gaining strength.

2. Sell Signals (Down Signal) Conversely, the indicator identifies "bearish crossovers" for sell opportunities. If the short-term trend drops below the long-term trend (specifically, if it was previously above it), a Down Signal appears. This indicates that downward pressure is becoming dominant.

3. Exit Long Signals To help manage existing positions, the script identifies when a buying trend may be losing steam. It looks for a crossover between the short-term and a middle-range "Exit" average, provided that the current price is trading above the primary long-term trend. This acts as a warning that the upward move might be reaching a point of exhaustion.

4. Exit Short Signals Similarly, for positions where you have sold (shorted), the script monitors the crossover between the short-term and the middle-range "Exit" average while the price is trading below the long-term trend. This provides a visual cue that the downward move may be stabilizing or reversing.

Visual Presentation

The logic translates these mathematical crossovers into clear visual markers on your chart:

  • Up Signals: Appear as arrows located slightly below the low of a candle.
  • Down Signals: Appear as arrows located slightly above the high of a candle.
  • Exit Signals: Use distinct markers to notify you when it may be appropriate to close an active position, helping to protect profits or limit losses based on the shifting momentum of the market.
Price Data Components
Series array that contains the lowest prices 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 %1
5 Views
0 Downloads
0 Favorites
wma_cross_confirm
//+------------------------------------------------------------------+
//|                                                       
//|                                                          Kalenzo |
//|                                                  simone@konto.pl |
//+------------------------------------------------------------------+

#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 int ShortPeriod = 5;
extern int BigPeriod = 50;
extern int ExitPeriod = 20;

#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,MODE_LWMA,PRICE_CLOSE,i+1);
      double cwma5 = iMA(Symbol(),0,ShortPeriod,0,MODE_LWMA,PRICE_CLOSE,i);
      
      double pwma50 = iMA(Symbol(),0,BigPeriod,0,MODE_LWMA,PRICE_CLOSE,i+1);
      double cwma50 = iMA(Symbol(),0,BigPeriod,0,MODE_LWMA,PRICE_CLOSE,i);
      
      double pwma20 = iMA(Symbol(),0,ExitPeriod,0,MODE_LWMA,PRICE_CLOSE,i+1);
      double cwma20 = iMA(Symbol(),0,ExitPeriod,0,MODE_LWMA,PRICE_CLOSE,i);
       
      if( cwma5 > cwma50 && pwma5 <= pwma50)
      {  
        UpBuffer[i] = iLow(Symbol(),0,i)-(3*Point);
        DnBuffer[i] = EMPTY_VALUE;
      }
      else if( pwma5 >= pwma50 && cwma5 < cwma50)
      {
        UpBuffer[i] = EMPTY_VALUE;
        DnBuffer[i] = iHigh(Symbol(),0,i)+(3*Point);
      }
      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