DynamicRS

This script is designed to provide traders with a visual representation of market structure by identifying dynamic "ceiling" and "floor" levels. Rather than using static horizontal lines, it calculates shifting support and resistance zones that evolve as the market moves, helping users identify potential areas where price might stall or reverse.

How the Logic Works

1. Establishing the Market Pulse (WBP) The script begins by analyzing the most recent price action over a short period to determine the current "weighted" value of the market. It does this by taking the highest price, the lowest price, and the current closing price, then averaging them together. This creates a smoothed baseline that reflects the immediate momentum of the assets.

2. Identifying the Trend Baseline (WBP_MA) To determine if the market is currently trending up or down, the script takes that "weighted" value and calculates a longer-term moving average. By comparing the current weighted value against this long-term average, the script can detect specific moments where the price trend shifts direction—essentially identifying when the market "crosses over" its own historical average.

3. Dynamic Resistance (The Ceiling) When the script detects that the short-term price momentum has dropped below its long-term average, it identifies a new Dynamic Resistance level. It captures the highest price point reached during that specific move and holds that value as a "ceiling" until another trend shift occurs. This shows traders where the market has previously struggled to break through from below.

4. Dynamic Support (The Floor) Conversely, when the price momentum moves above its long-term average, the script identifies a new Dynamic Support level. It captures the lowest price point during that move and holds it as a "floor" until the next trend shift. This highlights the areas where the market has historically found enough buying interest to keep the price from falling further.

5. The MeanSwing (The Equilibrium) Finally, the script calculates a third line called the MeanSwing. This is simply the halfway point between the Dynamic Resistance and the Dynamic Support. This serves as a visual "center of gravity" for the current market range, allowing traders to see the balance between the upper and lower boundaries.

Summary for the User

In plain terms, this tool automatically tracks the "highs" and "lows" of significant market swings. It draws a Red line to show you where the price is hitting resistance (the ceiling), a Green line to show you where it is finding support (the floor), and a Gray dashed line to show you the middle equilibrium between those two points. As the market creates new trends, these lines automatically update to reflect the newest price boundaries.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
DynamicRS
/*

Original Formula

WH:=HHV(HIGH,5);
WL:=LLV(LOW,5);
WBP:=(HHV(HIGH,5)+LLV(LOW,5)+CLOSE)/3;

RBAND:=VALUEWHEN(1,CROSS(MOV(WBP,25,S),WBP),
HHV(WH,25));


SBAND:=VALUEWHEN(1,CROSS(WBP,MOV(WBP,25,S)),
LLV(WL,25));

MSWNG:=(RBAND+SBAND)/2;

*/


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 Gray

//---- input parameters
extern int ShortPeriod=5;
extern int LongPeriod=25;

//---- buffers  WHH=HHV(WH,25);WLL=LLV(WL,25);WBP_MA=MOV(WBP,25,S)
double S[];
double R[];
double MS[];
double WBP[],WBP_MA[];



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- name for DataWindow and indicator subwindow label


   SetIndexBuffer(3, WBP);

   SetIndexBuffer(4, WBP_MA);



//----
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0, R);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);SetIndexBuffer(1, S);
   SetIndexStyle(2,DRAW_LINE,STYLE_DASHDOT,2);SetIndexBuffer(2, MS);  
   short_name="Dynamic Support/Resistance";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"Dynamic Resistance");
   SetIndexLabel(1,"Dynamic Support");
   SetIndexLabel(2,"MeanSwing");
   SetIndexDrawBegin(0,LongPeriod);
 SetIndexDrawBegin(1,LongPeriod);
  SetIndexDrawBegin(2,LongPeriod); 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Dynamic Support/Resistance                                        |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k,counted_bars=IndicatorCounted();
   
   if(Bars<=LongPeriod) return(0);
//---- initial zero

//---- last counted bar will be recounted
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++; else { i=limit;
            {R[i]=High[i];S[i]=Low[i];}
          }

//---- WH,WL,WBP calculation

   for(i=0; i<limit; i++)
      WBP[i] = (High[Highest(NULL,0,MODE_HIGH,ShortPeriod,i)] + Low[Lowest(NULL,0,MODE_LOW,ShortPeriod,i)] + Close[i])/3;


//---- WBP MA calculation
for(i=0; i<limit; i++)
WBP_MA[i]=iMAOnArray(WBP,Bars,LongPeriod,0,MODE_SMA,i);



//---- Drawing Lines
for(i=limit-1; i>=0; i--)
  if (WBP[i+1]>WBP_MA[i+1] && WBP[i]<WBP_MA[i])
      R[i]=High[Highest(NULL,0,MODE_HIGH,ShortPeriod+LongPeriod,i)];
        else R[i]=R[i+1];
for(i=limit-1; i>=0; i--)
   if (WBP[i+1]<WBP_MA[i+1] && WBP[i]>WBP_MA[i])
      S[i]=Low[Lowest(NULL,0,MODE_LOW,ShortPeriod+LongPeriod,i)];
        else S[i]=S[i+1];
   for(i=0; i<limit; i++)
      MS[i]=(R[i]+S[i])/2;
/**/
   return(0);
  }
//+------------------------------------------------------------------+

Comments