wma_cross_delta
Download scriptThis technical indicator is designed to identify potential trend reversals and momentum shifts on a trading chart by analyzing the relationship between two different moving averages. It acts as a visual signaling tool, highlighting specific moments where price action suggests a shift in direction.
Core Logic and Methodology
The script operates by tracking two distinct types of moving averages simultaneously: a Short-Term Average (designed to capture immediate price momentum) and a Long-Term Average (designed to represent the broader trend).
The logic identifies "signals" based on the relative positioning of these two averages compared to one another, combined with a specific "Delta" or buffer zone.
How the Signals are Generated
The indicator looks for specific crossover behaviors that occur when the short-term average moves rapidly across the long-term average:
- Buy Signals: A buy signal is triggered when the current short-term value crosses above the long-term value, provided it has moved past a pre-defined minimum distance (the Delta). Specifically, it looks for a moment where the previous candle's short-term average was still below the threshold, while the current one has surged above it. When this occurs, an upward arrow appears on the chart.
- Sell Signals: A sell signal is triggered when the short-term value crosses below the long-term value, again moving past the designated Delta distance. It identifies the point where the previous candle's short-term average was still above the threshold, but the current one has dropped below it. When this occurs, a downward arrow appears on the chart.
User Customization and Alerts
To make the tool more functional for active trading, the script includes several customizable notification features:
- Visual Feedback: The script places distinct arrows on the chart (Aqua for Buy, Magenta for Sell) to clearly mark the entry points without cluttering the price candles.
- Audio and Visual Alerts: Users can enable specific notifications that will trigger a sound effect, a pop-up alert window, or an on-screen text comment whenever a new signal is detected.
- Dynamic Calculations: The logic allows for different types of moving average calculations (such as Simple, Exponential, Smooth, or Linear Weighted) and customizable periods, allowing the user to tune the sensitivity of the signals based on their specific trading style.
In summary, this script automates the process of monitoring "cross-over" events between fast and slow price averages, filtering out minor fluctuations by requiring a minimum movement distance before confirming a signal.
//+------------------------------------------------------------------+
//| |
//| Kalenzo |
//| simone@konto.pl |
//| Modified by increase and Newdigital |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "simone@konto.pl"
#property indicator_chart_window
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_width1 5
#property indicator_width2 5
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 = 15;
extern int DeltaForBuy = 15;
#property indicator_buffers 2
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];
double alertBar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
// IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
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+(DeltaForBuy*Point)))
{
UpBuffer[i] = iLow(Symbol(),0,i)-(3*Point);
DnBuffer[i] = EMPTY_VALUE;
if (UseSound==1) PlaySound(NameFileSound);
if (UseAlert==1 && Bars>alertBar) {Alert(Symbol(), "Buy signal", Period());alertBar = Bars;}
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 - (DeltaForSell*Point)) && cwma5 < (cwma50 - (DeltaForSell*Point)))
{
UpBuffer[i] = EMPTY_VALUE;
DnBuffer[i] = iHigh(Symbol(),0,i)+(3*Point);
if (UseSound==1) PlaySound(NameFileSound);
if (UseAlert==1 && Bars>alertBar) {Alert(Symbol(), "Sell signal", Period());alertBar = Bars;}
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