Ind-Widners_Oscilator

Download script
Ind-Widners_Oscilator

The Ind-Widners Oscillator is a specialized technical analysis tool designed to provide traders with a visual representation of price momentum and extreme value detection. Instead of simply looking at where the price is moving now, this script analyzes historical "peaks" and "valleys" to calculate a relative strength score.

Core Logic Overview

The script operates by scanning a specific number of previous price bars (determined by the user's period setting) to identify the most significant price points. It focuses on two distinct types of data: the lowest prices (bottoms) and the highest prices (tops).

By isolating these extreme points, the tool creates a "memory" of the market's volatility. It captures six specific data points for both the highs and the lows within each timeframe, effectively creating a profile of where the price has struggled to move or where it has surged.

How the Calculations Work

The logic follows a two-step process to generate the lines you see on your chart:

1. Identification of Extremes The script moves backwards through time, identifying the highest and lowest prices reached over a set period. Every time it finds a new peak or valley that matches its criteria, it updates its internal memory of those six key points.

2. The Momentum Score Once the six high points and six low points are identified, the script compares them against the current closing price.

  • It calculates how many times these historical extremes "fit" into the current price.
  • This creates a percentage-based score between 0 and 100.
  • The script then produces two separate lines: one based on the "Low" peaks (representing downward pressure or oversold conditions) and one based on the "High" peaks (representing upward pressure or overbought conditions).

Visual Interpretation for Traders

Because the results are normalized between 0 and 100, the indicator provides a clear boundary for market sentiment:

  • Movement toward 100: Indicates that the price is moving significantly away from historical lows, suggesting strong upward momentum.
  • Movement toward 0: Indicates that the price is pulling back toward historical highs or showing significant downward pressure.
  • Stability Controls: To prevent the lines from hitting hard "walls" at 0 or 100 (which can sometimes distort the visual flow of the trend), the logic includes a small adjustment that keeps the values slightly within the boundaries, ensuring a smoother visual experience for the user.

In summary, this tool helps traders see the relationship between current market activity and past price extremes, allowing for a clearer understanding of whether the market is overextended or gaining significant new ground.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
Ind-Widners_Oscilator
//+------------------------------------------------------------------+
//|                                        Ind-Widners Oscilator.mq4 |
//|                    Copyright © 2004, http://www.expert-mt4.nm.ru |
//|                                      http://www.expert-mt4.nm.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, http://www.expert-mt4.nm.ru"
#property link      "http://www.expert-mt4.nm.ru"

#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

extern int nPeriod=9;
extern int Limit=350;
///---- int Widners Oscilator
int cnt,nCurBar;
//---- buffers
double wso[];
double wro[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,wso);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,wro);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//---- TODO: add your code here
   double r1,r2,r3,r4,r5,r6;
   double s1,s2,s3,s4,s5,s6;
//---- ????? ????????????? ? ?????????
if(Bars>Limit) Limit=Bars-nPeriod;
for(nCurBar=Limit; nCurBar>0; nCurBar--)
   {
   if(Low[nCurBar+(nPeriod-1)/2] == Low[Lowest(NULL,0,MODE_LOW,nPeriod,nCurBar)])
      {
      s6=s5; s5=s4; s4=s3; s3=s2; s2=s1; s1=Low[nCurBar+(nPeriod-1)/2];
      }
   if(High[nCurBar+(nPeriod-1)/2] == High[Highest(NULL,0,MODE_HIGH,nPeriod,nCurBar)])
      {
      r6=r5; r5=r4; r4=r3; r3=r2; r2=r1; r1=High[nCurBar+(nPeriod-1)/2];
      }
//----
   wso[nCurBar]=100*(1-(MathFloor(s1/Close[nCurBar])+
               MathFloor(s2/Close[nCurBar])+
               MathFloor(s3/Close[nCurBar])+
               MathFloor(s4/Close[nCurBar])+
               MathFloor(s5/Close[nCurBar])+
               MathFloor(s6/Close[nCurBar]))/6);
	if(wso[nCurBar]==0) wso[nCurBar]=wso[nCurBar]+1;
	if(wso[nCurBar]==100) wso[nCurBar]=wso[nCurBar]-1;

   wro[nCurBar]=100*(1-(MathFloor(r1/Close[nCurBar])+
               MathFloor(r2/Close[nCurBar])+
               MathFloor(r3/Close[nCurBar])+
               MathFloor(r4/Close[nCurBar])+
               MathFloor(r5/Close[nCurBar])+
               MathFloor(r6/Close[nCurBar]))/6);
	if(wro[nCurBar]==0) wro[nCurBar]=wro[nCurBar]+1;
	if(wro[nCurBar]==100) wro[nCurBar]=wro[nCurBar]-1;
   }
//----
   return(0);
  }


Comments