squeak_!oscilator

Download script
squeak_!oscilator

This script is a specialized technical analysis tool designed to filter and visualize momentum dynamics within the MetaTrader platform. Rather than simply displaying raw price data, it interprets the relationship between price velocity and standard market oscillators to identify specific trends.

Core Logic Overview

The tool functions by analyzing the Stochastic Oscillator, a common momentum indicator, but adds a unique mathematical layer to determine "squeezing" or directional strength. It essentially looks for points where the speed of price movement aligns with the underlying momentum of the market.

How the Script Processes Data

  1. Data Input Selection: The logic allows users to choose between different moving average types (such as Simple, Exponential, or Weighted) and decide whether to base the calculations on "High-Low" price ranges or simple "Closing" prices.
  2. Momentum Calculation: The script retrieves two consecutive points from the Stochastic Oscillator. It then calculates the difference between current and previous closing prices to determine how fast the market is moving in a specific direction.
  3. The Correlation Filter: The tool multiplies these two values together. By doing this, it identifies whether the price move is happening in harmony with the oscillator's momentum.
  4. Dynamic Tracking:
    • Bullish Identification: When the correlation is positive and meets certain mathematical thresholds, the script identifies a potential upward trend (Bullish).
    • Bearish Identification: When the correlation is negative and meets specific thresholds, it identifies a potential downward trend (Bearish).
  5. Visual Output: Instead of a standard line, the script generates a histogram. It tracks these values over time, highlighting periods where the "squeezing" logic confirms a shift in market behavior.

User Experience

For the end-user, this means the tool acts as a specialized filter. It ignores "noisy" price movements that don't have supporting momentum and focuses on visualizing the specific moments where price action and oscillator strength synchronize, providing a clearer picture of the current market trend.

Indicators Used
Stochastic oscillator
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
squeak_!oscilator
//2009.12.21
//+------------------------------------------------------------------+
//| Oscillator squeaker! ;stochastic based.
//+------------------------------------------------------------------+
#property copyright "Copyright (c) 2009 KurlFX"//Stochastic
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 Lavender
#property indicator_color4 Linen
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_level1 0.0
#property indicator_levelstyle STYLE_SOLID
#property indicator_levelcolor Black
#property indicator_maximum 1
#property indicator_minimum -1
//---- buffers
double BufS[];
double BufL[];
double BufQ[];
double Bufq[];
//---- parameters
extern int Kperiod=50;
extern int Dperiod=3;
extern int Slowing=3;
extern int Method=0;//0:SMA,1:EMA,2:SMMA,3:LWMA
extern int Price_field=1;//0:Low-High,1:Close-Close
extern int Mode=0;//0:main,1:signal
//+------------------------------------------------------------------+
//| init
//+------------------------------------------------------------------+
int init()
{
	switch(Method)
	{
		case 0:string method="SMA";break;
		case 1:method="EMA";break;
		case 2:method="SMMA";break;
		case 3:method="LWMA";break;
	}
	switch(Price_field)
	{
		case 0:string pf="(Lo/Hi)";break;
		case 1:pf="(Close)";break;
	}
	switch(Mode)
	{
		case 0:string mode="MODE_MAIN";break;
		case 1:mode="MODE_SIGNAL";break;
	}
	IndicatorShortName("squeak!_Stochastic("+Kperiod+","+Dperiod+","+Slowing+")"+method+pf+mode);
	//IndicatorBuffers(3);
	SetIndexBuffer(0,BufS);SetIndexLabel(0,"sq?Bear");SetIndexStyle(0,DRAW_HISTOGRAM);
	SetIndexBuffer(1,BufL);SetIndexLabel(1,"sq?Bull");SetIndexStyle(1,DRAW_HISTOGRAM);
	SetIndexBuffer(2,BufQ);SetIndexLabel(2,NULL);SetIndexStyle(2,DRAW_HISTOGRAM);
	SetIndexBuffer(3,Bufq);SetIndexLabel(3,NULL);SetIndexStyle(3,DRAW_HISTOGRAM);
	return(0);
}
//+------------------------------------------------------------------+
//| start
//+------------------------------------------------------------------+
int start()
{
	static double Buf=0.0;
	int cntbar=IndicatorCounted();
	if(Volume[0]==1)cntbar=0;
	int limit=Bars-cntbar;
	if(cntbar==0){limit-=Kperiod+Dperiod+Slowing+1;BufL[limit+1]=0;BufS[limit+1]=0;}
	for(int i=limit;i>=0;i--)
	{
		BufL[i]=EMPTY_VALUE;BufS[i]=EMPTY_VALUE;BufQ[i]=EMPTY_VALUE;Bufq[i]=EMPTY_VALUE;
		double bs0=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,Method,Price_field,Mode,i);
		double bs1=iStochastic(NULL,0,Kperiod,Dperiod,Slowing,Method,Price_field,Mode,i+1);
		double c0=Close[i],c1=Close[i+1];
		double k=(c0-c1)/Point,kk=(bs0-bs1),kkk=k*kk,kkkk;
		if(kkk>0){if(k<0)kkk*=-1;if(MathAbs(kkk)>100)kkk/=100;kkkk=kkk/100.0+1/kkk;}else{kkk=0;}
		if(kkk>0)
		{
			if(Buf<=0)
			{
				if(kkk>-Buf){BufL[i]=kkkk;Buf=kkk;}
			}
			else
			{BufL[i]=kkkk;Buf=kkk;}
		}
		else if(kkk<0)
		{
			if(Buf>=0)
			{
				if(kkk<-Buf){BufS[i]=kkkk;Buf=kkk;}
			}
			else
			{BufS[i]=kkkk;Buf=kkk;}
		}
		else
		{BufL[i]=BufL[i+1];BufS[i]=BufS[i+1];}
		//*
		if(BufL[i]==EMPTY_VALUE&&BufS[i]==EMPTY_VALUE)
		{
			kkk=Buf/100+1/Buf;
			if(kkk>0)BufQ[i]=kkk;else Bufq[i]=kkk;
		}
	}
   return(0);
}
//+------------------------------------------------------------------+

Comments