Overview
The SilverTrend Signal is a specialized technical analysis tool designed to identify potential entry points in financial markets by analyzing price action and volatility. Rather than relying on standard moving averages, this script focuses on identifying "extremes"—specific moments where the price reaches a peak or a valley relative to its recent history—and alerts the user when the price breaks into these zones.
Core Logic and Methodology
The indicator operates through three primary logical steps:
1. Volatility Measurement (Range Calculation) Before determining a signal, the script calculates a "Range" value. It looks at a specific window of recent candles to measure the distance between highs and lows. By calculating this spread, the tool attempts to understand how much the market is currently swinging. This information is used to determine the physical placement of the visual signals on your chart, ensuring they appear at an appropriate distance from the actual price bars.
2. Historical Peak and Valley Detection The script constantly monitors a defined "Period" (the look-back window). Within this window, it identifies:
- The highest price reached (High).
- The lowest price reached (Low).
It then establishes a dynamic boundary based on your "Step Back" setting. This creates a "buffer zone" near the top and bottom of that historical range.
3. Signal Generation (Buy and Sell Logic) The tool generates visual markers (arrows) based on the relationship between the current closing price and the identified boundaries:
- Sell Signals: If the current market price closes significantly above the highest point of the recent period (adjusted by your buffer), the script identifies a potential reversal or exhaustion point. It then places a signal marker above the candle.
- Buy Signals: If the current market price closes significantly below the lowest point of the recent period (adjusted by your buffer), the script identifies a potential "oversold" condition and places a signal marker below the candle.
User Notifications
Beyond visual markers, the script includes an integrated notification system. If enabled by the user, the tool can monitor these price breaks in real-time. When a specific threshold is crossed (triggering a Buy or Sell signal), the system can be configured to send automated alerts directly to your email, allowing you to monitor market movements even when you are not actively looking at the charts.
Key Customization Parameters
- Period: Determines how far back into the past the script looks to find the highest highs and lowest lows.
- Step Back: Adjusts the sensitivity of the "buffer zone." A higher value requires a more significant price move to trigger a signal, while a lower value makes the indicator more sensitive to smaller price fluctuations.
- Alert Settings: Controls whether you wish to receive audible alerts or automated emails when a new signal is detected.
//+------------------------------------------------------------------+
//| SilverTrend_Signal.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property copyright "SilverTrend rewritten by CrazyChart"
#property link "http://viac.ru/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 DeepPink
#property indicator_width1 5
#property indicator_width2 5
#define SH_BUY 1
#define SH_SELL -1
//---- Âõîäíûå ïàðàìåòðû
extern int AllBars=0;//How many bars should be counted. 0 - all the bars.
extern int Otstup=2;//Step back.
extern double Per=7;//Period.
extern string
Alert_Setting = "---------- Alert Setting";
extern bool
EnableAlert = false;
extern bool
Email_ON = true;
extern string
SoundFilename = "alert.wav";
int SH,NB,i,UD,x=0,y=0,a=0,b=0;
double R,SHMax,SHMin;
double BufD[];
double BufU[];
double alertBar;
//+------------------------------------------------------------------+
//| Ôóíêöèÿ èíèöèàëèçàöèè |
//+------------------------------------------------------------------+
int init()
{
//We will write the number of the bars for which we are counting to the NB
if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
IndicatorBuffers(2);
IndicatorShortName("SHI_08");
SetIndexStyle(0,DRAW_ARROW,0,5);
SetIndexStyle(1,DRAW_ARROW,0,5);
SetIndexArrow(0,159);
SetIndexArrow(1,159);
SetIndexBuffer(0,BufU);
SetIndexBuffer(1,BufD);
SetIndexDrawBegin(0,Bars-NB);//This indicator will be shown for NB bar only
SetIndexDrawBegin(1,Bars-NB);
ArrayInitialize(BufD,0.0);//Give a lot of "zero" to the buffe. Otherwise it will be garbage during the changing of time frame.
ArrayInitialize(BufU,0.0);
return(0);
}
//+------------------------------------------------------------------+
//| Ôóíêöèÿ äåèíèöèàëèçàöèè |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Ñîáñíà èíäèêàòîð |
//+------------------------------------------------------------------+
int start()
{
int CB=IndicatorCounted();
/* It is the optimization option. We have the function here which restore/return the number of counted bars in very special way.
During the first indicator's call we have 0: it is normal because it was not counted anything,
and then we receive the number of bars minus 1. For example, if the number of bars equal 100,
we will have 99. I did it especially, you may see that NB is the number of bars whioch should be counted.
You know we may throw out this parameter. But for the people who understand we may keep it. So, during the first call
of indicator this NB is the same one but during the 2dn etc calls - reducing the value up to the last bar,
That is 1 or 2 for example*/
if(CB<0)return(-1);else if(NB>Bars-CB)NB=Bars-CB;
for(SH=1;SH<NB;SH++)//comb out the chart from 1 to NB
{
for(R=0,i=SH;i<SH+10;i++)
{
R+=(10+SH-i)*(High[i]-Low[i]);
}
R/=55;
SHMax=High[Highest(NULL,0,MODE_HIGH,Per,SH)];
SHMin=Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
if(Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100&&UD!=SH_BUY)
{
BufD[SH]=High[SH]+R*0.5;
if(Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100&&UD!=SH_BUY)UD=SH_BUY;
if(Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100&&UD!=SH_BUY)y=0;//x=x+1;
}
else
if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100&&UD!=SH_SELL)
{
BufU[SH]=Low[SH]-R*0.5;
if(Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100&&UD!=SH_SELL)UD=SH_SELL;
if(Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100&&UD!=SH_SELL)x=0;//y=y+1;
}
}
//----------------------- ALERT ON UP / DOWN DOT
if(EnableAlert)
{
string AlertComment;
if(Email_ON&&Bars>alertBar)
{ // Alert(Symbol() + " M("+Period()+") - VM BUY");
if(Email_ON)SendMail(StringConcatenate(Symbol(),"S hi signal"),"Shi BUY");
}
if(Email_ON&&Bars>alertBar)
{ // Alert(Symbol() + " M("+Period()+") - VM SELL");
if(Email_ON)SendMail(StringConcatenate(Symbol(),"S hi signal"),"Shi SELL");
}
}
//----------------------- END FUNCTION
return(0);
}
Comments