Author: Kalenzo
BB_PRC

This tool is designed to help traders identify specific price actions and momentum shifts by analyzing where the current market price sits relative to a volatility range. It creates a unique visual representation of the market's "position" rather than just looking at raw price data.

Core Logic and Data Processing

The script functions by breaking down the market movement into three distinct layers:

1. Relative Position Calculation (The "Bol" Value) Instead of simply looking at whether a price is "high" or "low," the script calculates a percentage-like value. It looks at a standard volatility band (Bollinger Bands) and determines where the current closing price sits between the upper and lower boundaries. This produces a normalized value that represents the market's relative location within its current range.

2. Trend Smoothing (The Moving Average) To filter out "noise" and minor fluctuations, the script applies a secondary calculation onto the relative position values. It creates a moving average of the data mentioned above. This helps the user see the broader trend of the price's relative position, making it easier to identify sustained movements versus temporary spikes.

Alert System and Trading Signals

The script is programmed to monitor these two values (the Relative Position and its Moving Average) in real-time to generate four specific types of notifications:

  • Extreme Low Detection: Triggered when the price reaches a relative low point within its range, specifically identifying a "bottoming" behavior.
  • Extreme High Detection: Triggered when the price hits a relative high point within its range, identifying a potential "peak" behavior.
  • Bearish Crossover (Sell Signal): An alert is sent when the relative price position drops below its smoothed moving average. This suggests that the current momentum is turning downward relative to recent history.
  • Bullish Crossover (Buy Signal): An alert is sent when the relative price position climbs above its smoothed moving average. This suggests that the current momentum is turning upward relative to recent history.

User Experience Features

To ensure the tool is practical for live trading, it includes a "sleep" mechanism for alerts. This prevents the system from sending multiple notifications for the same movement, ensuring you only receive one alert per significant event within a defined timeframe.

Indicators Used
Bollinger bands indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
14 Views
0 Downloads
0 Favorites
BB_PRC
//+------------------------------------------------------------------+
//|                                                       BB_PRC.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
#property indicator_color1 Red
#property indicator_color2 Gold
#property indicator_buffers 2

double bol[];
double ma[];
extern int bPer=20,bDev=2,maPer=50,maMeth=MODE_EMA;
extern bool useAlerts = true;
extern int alertBar = 1;
extern int alertSleep = 1800;//in seconds
int lastAlert;
#property indicator_separate_window

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,bol);
   SetIndexStyle(0,DRAW_LINE,EMPTY,2);
   
   SetIndexBuffer(1,ma);
   SetIndexStyle(1,DRAW_LINE,EMPTY,1);
   
   IndicatorShortName("BB PRC RANGE v1");
//----
   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-bPer;
   
   for(int i=0; i<=limit;i++)
   {
      double bandL = iBands(Symbol(),0,bPer,bDev,0,PRICE_CLOSE,MODE_MINUSDI,i);
      double bandH = iBands(Symbol(),0,bPer,bDev,0,PRICE_CLOSE,MODE_PLUSDI,i);
      bol[i] = ((Close[i]-bandL)/(bandH-bandL));
      
      if((Close[i]-bandL)==0 || (bandH-bandL)==0)
      Print(i," ",(Close[i]-bandL)," ",(bandH-bandL));
   }
   
   for(int j=0; j<=limit;j++)
   {
      ma[j] = iMAOnArray(bol,0,maPer,0,maMeth,j);      
   }
   
   if(useAlerts)
   {
      if( ma[alertBar] >= bol[alertBar] && CurTime()>lastAlert && (bol[2+alertBar] >= bol[1+alertBar]) && (bol[1+alertBar] < bol[alertBar]))
      {
         Alert("BB PRC MADE LOW");
         lastAlert = CurTime()+alertSleep;
      }
      
      if( ma[alertBar] <= bol[alertBar] && CurTime()>lastAlert && (bol[2+alertBar] <= bol[1+alertBar]) && (bol[1+alertBar] > bol[alertBar]))
      {
         Alert("BB PRC MADE HIGH");
         lastAlert = CurTime()+alertSleep;
      }
      
      if( CurTime()>lastAlert && bol[alertBar+1] >= ma[alertBar+1] && bol[alertBar] < ma[alertBar])
      {
         Alert("BB PRC CROSSED MA FOR SELL");   
         lastAlert = CurTime()+alertSleep;
      }   
      
      if( CurTime()>lastAlert && bol[alertBar+1] <= ma[alertBar+1] && bol[alertBar] > ma[alertBar])
      {
         Alert("BB PRC CROSSED MA FOR BUY");   
         lastAlert = CurTime()+alertSleep;
      }
   }
   
   return(0);
  }
//+------------------------------------------------------------------+

Comments