13008d1155015516-indicators-alert-signal-shi_silvertrendsigalert

Download script
Author: Copyright � 2005, Shurka
13008d1155015516-indicators-alert-signal-shi_silvertrendsigalert

This tool is a visual trading indicator designed to identify potential trend reversal points on a price chart. It works by analyzing historical price action—specifically looking at the relationship between recent highs and lows—to signal when the market might be shifting direction.

How the Logic Works

The script scans the market history using several layers of data analysis:

1. Price Range Evaluation The tool constantly monitors a specific window of time (defined by a user-set period). Within this window, it identifies the highest price reached and the lowest price recorded. By calculating the difference between these two extremes, it establishes the current "volatility range."

2. Trend Signal Detection Instead of simply reacting to every price move, the logic looks for specific "oversold" or "overbought" conditions:

  • Buy Signals: The script identifies a situation where the closing price drops significantly toward the bottom of the established range. If the price enters this lower threshold, it triggers an upward signal.
  • Sell Signals: Conversely, if the closing price rises significantly toward the top of the range, the script identifies a potential peak and triggers a downward signal.

3. Dynamic Filtering To ensure the signals are meaningful, the tool uses a custom weight calculation based on the "spread" (the difference between the high and low prices) of several preceding bars. This helps place the visual markers at an appropriate distance from the price candles, ensuring they remain visible and easy to read without cluttering the chart.

4. Smart Alerts and Optimization The script includes built-in logic to manage how it communicates with the user:

  • Single Notification: It is programmed to only trigger one alert per candle. This prevents the system from sending continuous, repetitive notifications for a single price move.
  • Visual Cues: It places distinct arrows on the chart (Blue for buy signals and Red for sell signals) so traders can see historical trend shifts at a glance.
  • Audible Alerts: When a new signal is confirmed at the start of a new candle, the script can trigger an audible sound to grab the trader's attention immediately.

Summary for the User

In simple terms, this indicator acts as a "boundary watcher." It marks the high and low points of recent trading and notifies you when the price pushes too far into those boundaries, suggesting that a reversal in the trend may be imminent.

Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt plays sound alerts
10 Views
0 Downloads
0 Favorites
13008d1155015516-indicators-alert-signal-shi_silvertrendsigalert
//+------------------------------------------------------------------+
//|                                           SHI_SilverTrendSig.mq4 |
//|          Copyright © 2003, VIAC.RU, OlegVS, GOODMAN, 2005 Shurka |
//|                                                 shforex@narod.ru |
//|                                                                  |
//|                                                                  |
//| Ïèøó ïðîãðàììû íà çàêàç                                          |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Shurka"
#property link      "http://shforex.narod.ru"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#define  SH_BUY   1
#define  SH_SELL  -1

//---- Âõîäíûå ïàðàìåòðû
extern int     AllBars=0;//Äëÿ ñêîëüêè áàðîâ ñ÷èòàòü. 0 - äëÿ âñåõ.
extern int     Otstup=30;//Îòñòóï.
extern double  Per=9;//Ïåðèîä.
extern bool    UseAlert = true;
extern string AlertSoundFile = "alert.wav";

int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];
//+------------------------------------------------------------------+
//| Ôóíêöèÿ èíèöèàëèçàöèè                                            |
//+------------------------------------------------------------------+
int init()
{
   // NB çàïèñûâàåì êîëè÷åñòâî áàðîâ äëÿ êîòîðûõ ñ÷èòàåì èíäèêàòîð
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   IndicatorBuffers(2);
   IndicatorShortName("SHI_SilverTrendSig");
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,BufU);
   SetIndexBuffer(1,BufD);
   SetIndexDrawBegin(0,Bars-NB);//Èíäèêàòîð áóäåòîòîáðàæàòüñÿ òîëüêî äëÿ NB áàðîâ
   SetIndexDrawBegin(1,Bars-NB);
   ArrayInitialize(BufD,0.0);//Çàáü¸ì îáà áóôåðà íîëèêàìè. Èíà÷å áóäåò ìóñîð ïðè ñìåíå òàéìôðåéìà.
   ArrayInitialize(BufU,0.0);
   return(0);
}
//+------------------------------------------------------------------+
//| Ôóíêöèÿ äåèíèöèàëèçàöèè                                          |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Ñîáñíà èíäèêàòîð                                                 |
//+------------------------------------------------------------------+
int start()
{
   int CB=IndicatorCounted();
   /* Òóò âîò òà ñàìàÿ îïòèìèçàöèîííàÿ ôèøêà.  ÿçûê ââåäåíà ôóíêöèÿ, êîòîðàÿ âîçâðàùàåò êîëè÷åñòâî
   ïîñ÷èòàííûõ áàðîâ, ïðè÷¸ì î÷åíü õèòðî. Ïðè ïåðâîì âûçîâå èíäèêàòîðà ýòî 0, âñ¸ ïîíÿòíî, åù¸ íè÷åãî
   íå ñ÷èòàëîñü, à çàòåì âûäà¸ò êîëè÷åñòâî îáñ÷èòàííûõ áàðîâ ìèíóñ îäèí. Ò.å. åñëè âñåãî áàðîâ 100,
   òî ôóíêöèÿ âåðí¸ò 99. ß ââ¸ë òàêîé êîä, âûøå ó ìåíÿ îïðåäåëÿëàñü NB - êîë-âî áàðîâ ïîäëåæàùèõ
   îáñ÷¸òó.  ïðèíöèïå ýòîò ïàðàìåòð ìîæíî è âûêèíóòü, îäíàêî äëÿ òåõ êòî â òàíêå (I80286) ìîæíî
   è îñòàâèòü. Òàê âîò, çäåñü, ïðè ïåðâîì âûçîâå NB îñòà¸òñÿ ïðåæíåé, à ïðè ïîñëåäóþùèõ óìåíüøàåòñÿ
   äî ïîñëåäíåãî áàðà, ò.å. 1 èëè 2, íó èëè ñêîëüêî òàì îñòàëîñü ïîñ÷èòàòü*/
   if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
   for (SH=1;SH<NB;SH++)//Ïðî÷¸ñûâàåì ãðàôèê îò 1 äî 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]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) { BufU[SH]=Low[SH]-R*0.5; UD=SH_SELL; DoAlert(UD);}
      if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY) { BufD[SH]=High[SH]+R*0.5; UD=SH_BUY;  DoAlert(UD);}
   }
   return(0);
}

void DoAlert(int UD)
{
   if (!NewBar() || !UseAlert)
      return;
   string sAction = "Buy";
   if (UD == SH_BUY) // Think there is a problem in the indicator. using Buy instead of sell
      sAction = "Sell";
      Alert(Symbol(), " ",Period()," alert!! ", sAction);
      PlaySound(AlertSoundFile); 	
}
bool NewBar()
{
   static datetime dt  = 0;
   if (dt != Time[0])
   {
      dt = Time[0];
      return(true);
   }
   return(false);
}


Comments