Technical Overview: Adaptosctry Logic
This script functions as a sophisticated technical analysis indicator designed to provide traders with smoothed, adaptive momentum insights. Unlike standard indicators that use a fixed timeframe or period for calculations, this logic dynamically determines its parameters based on market structure and "extremes."
Core Operational Logic
1. Dynamic Extreme Detection The primary engine of this script is its ability to identify significant price fluctuations automatically. Instead of relying on a user-defined constant (like a 14-day moving average), it scans historical data to find specific "extremes"—peaks and valleys in the market movement.
By analyzing the relationship between consecutive price points, the script identifies local highs and lows. It uses these detected extremes to establish unique, variable time periods for its calculations. This allows the indicator to "adapt" to the current volatility of the market; in fast-moving markets, it adjusts its sensitivity, and in quiet markets, it expands its view.
2. Multi-Layered Momentum Analysis The script generates three distinct data streams (buffers) to provide a comprehensive view of price action:
- Primary Variable: The first line represents an RSI (Relative Strength Index) calculation based on the very first significant extreme detected by the logic. This captures the immediate momentum of recent price changes.
- Secondary Variable: The second line represents an RSI calculation based on a deeper, more significant extreme. By looking further back or at a different "tier" of market peaks/valleys, this provides a broader context of the trend.
- Composite Average: The third line is a mathematical blend (the average) of the two previous lines. This acts as a smoothed signal, filtering out "noise" and providing a clearer picture of the overall trend direction.
Key Features for the User
- Self-Adjusting Periods: Because the script calculates its own lookback periods based on price extremes, it reacts dynamically to market conditions rather than remaining static.
- Visual Smoothing: By averaging two different types of momentum readings into a single final line, the tool helps traders distinguish between temporary price fluctuations and sustained trend movements.
- Customizable Sensitivity: Users can define the "count" of extremes (how many peaks/valleys the script should look for), allowing them to tune how aggressively or conservatively the indicator reacts to market volatility.
In summary, this script acts as an intelligent filter that identifies the "rhythm" of the market by looking at historical highs and lows, converting that data into a smoothed momentum signal that tells you where the price is heading relative to its recent history.
//+------------------------------------------------------------------+
//| Adaptosctry.mq4 - let it be |
//| Copyright © Telemah |
//| mailto:savemih@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © Telemah"
#property link "mailto:savemih@mail.ru"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 DarkTurquoise
#property indicator_color2 Red
#property indicator_color3 Yellow
extern int CountBars=1000;
//extern double Po2=40; //Äëÿ âàðèàíòîâ ñ êîëè÷åñòâîì äâèæåíèÿ
//extern double Po1=120;
extern int nExtr1=3;
extern int nExtr2=6;
//extern int nFract1=2;
//extern int nFract2=6;
//extern int stochD=3; //Äëÿ ñòîõàñòèêà
//extern int stochslow=3;
//---- buffers
double Buf[];
double Buf1[];
double Buf2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(3);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,Buf);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Buf1);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,Buf2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Ind |
//+------------------------------------------------------------------+
int start()
{
SetIndexDrawBegin(0,Bars-CountBars+101);
SetIndexDrawBegin(1,Bars-CountBars+101);
SetIndexDrawBegin(2,Bars-CountBars+101);
int i,i1,i2,counted_bars=IndicatorCounted();
double con1,con2,Pe1,Pe2;
int iFlow[50],iFhigh[50],iEx[50],iExF[50],n,nl,nh,nf;
double BufCus[1000],BufFUP[1000],BufFLO[1000],pEx[50],pF[50],
pFhigh[50],pFlow[50],Fhigh[50],Flow[50],pEXhigh[50],pEXlow[50];
//----
if(CountBars<=101) return(0);
//---- initial zero
if(counted_bars<101)
{
for(i=1;i<=0;i++) Buf[CountBars-i]=0.0;
for(i=1;i<=0;i++) Buf1[CountBars-i]=0.0;
for(i=1;i<=0;i++) Buf2[CountBars-i]=0.0;
}
//----
i=CountBars-101-1;
// if(counted_bars>=101) i=Bars-counted_bars-1;
while(i>=0)
{
//++++++++++++++++++++++++++++++++++++++++++++++
//Äëÿ âàðèàíòîâ ñ êîëè÷åñòâîì äâèæåíèÿ
/*
for (i1=1;i1<=100;i1++)
{
con1+=MathAbs(Close[i+i1]-Open[i+i1]);
if (con1>=Po1*Point) {Pe1=i1;break;}
}
for (i2=1;i2<=100;i2++)
{
con2+=MathAbs(Close[i+i2]-Open[i+i2]);
if (con2>=Po2*Point) {Pe2=i2;break;}
}
con1=0;
con2=0;
*/
//+++++++++++++++++++++++++++++++++++++++++
//Äëÿ âàðèàíòîâ ñ ýêñòðåìóìàìè
BufCus[i]=iCustom(NULL,0,"FATL",CountBars,0,i);
for (i1=1;i1<=100;i1++)
{
if ((BufCus[i+i1]>BufCus[i+i1+1] && BufCus[i+i1+1]<BufCus[i+i1+2]) ||
(BufCus[i+i1]<BufCus[i+i1+1] && BufCus[i+i1+1]>BufCus[i+i1+2]))
{
n=n+1;iEx[n]=i1;pEx[n]=Close[i1];
if (n==nExtr1) {Pe1=iEx[n];}
if (n==nExtr2) {Pe2=iEx[n];}
}
/*
+++++++++++++++++++++++++++++++++++++++++++++++
if (BufCus[i+i1]>BufCus[i+i1+1] && BufCus[i+i1+1]<BufCus[i+i1+2])
{nl=nl+1;Flow[nl]=BufCus[i+i1+1];iFlow[nl]=i1;
pEXlow[nl]=Close[i1];}
if (BufCus[i+i1]<BufCus[i+i1+1] && BufCus[i+i1+1]>BufCus[i+i1+2])
{nh=nh+1;Fhigh[nh]=BufCus[i+i1+1];iFhigh[nh]=i1;
pEXhigh[nh]=Close[i1];}
+++++++++++++++++++++++++++++++++++++++++++++++
*/
}
n=0;
/*
+++++
nl=0;
nh=0;
+++++
*/
//++++++++++++++++++++++++++++++++++++++++
//Âàðèàíòû ñ êîëè÷åñòâîì ôðàêòàëîâ
/*
BufFUP[i]=iFractals(NULL,0,MODE_UPPER,i);
BufFLO[i]=iFractals(NULL,0,MODE_LOWER,i);
for (i1=3;i1<=103;i1++)
{
if (BufFUP[i+i1]!=0 || BufFLO[i+i1]!=0)
nf=nf+1;iExF[nf]=i1;pF[nf]=Close[i1]
if (nf==nFract1) {Pe1=iExF[nf];}
if (nf==nFract2) {Pe2=iExF[nf];}
}
nf=0;
*/
//++++++++++++++++++++++++++++++++++++++++
//Buf[i]=iCCI(NULL,0,Pe1,PRICE_CLOSE,i);
//Buf1[i]=iCCI(NULL,0,Pe2,PRICE_CLOSE,i);
Buf[i]=iRSI(NULL,0,Pe1,PRICE_CLOSE,i);
Buf1[i]=iRSI(NULL,0,Pe2,PRICE_CLOSE,i);
//Buf[i]=iStdDev(NULL,0,Pe1,MODE_SMA,0,PRICE_CLOSE,i);
//Buf1[i]=iStdDev(NULL,0,Pe2,MODE_SMA,0,PRICE_CLOSE,i);
//Buf[i]=iADX(NULL,0,Pe1,PRICE_CLOSE,MODE_MAIN,i);
//Buf1[i]=iADX(NULL,0,Pe2,PRICE_CLOSE,MODE_MAIN,i);
//Buf[i]=iStochastic(NULL,0,Pe1,stochD,stochslow,MODE_SMA,PRICE_CLOSE,MODE_MAIN,i);
//Buf1[i]=iStochastic(NULL,0,Pe2,stochD,stochslow,MODE_SMA,PRICE_CLOSE,MODE_MAIN,i);
//Buf[i]=iWPR(NULL,0,Pe1,i);
//Buf1[i]=iWPR(NULL,0,Pe2,i);
//Buf[i]=iForce(NULL,0,Pe1,MODE_SMA,PRICE_CLOSE,i);
//Buf1[i]=iForce(NULL,0,Pe2,MODE_SMA,PRICE_CLOSE,i);
//Buf[i]=iWPR(NULL,0,Pe1,i);
//Buf1[i]=iWPR(NULL,0,Pe2,i);
//Buf[i]=iRVI(NULL,0,Pe1,MODE_MAIN,i);
//Buf1[i]=iRVI(NULL,0,Pe2,MODE_MAIN,i);
//Buf[i]=iDeMarker(NULL,0,Pe1,i);
//Buf1[i]=iDeMarker(NULL,0,Pe2,i);
//Buf[i]=iMFI(NULL,0,Pe1,i);
//Buf1[i]=iMFI(NULL,0,Pe2,i);
//Buf[i]=iCustom(NULL,0,"J_TPO",Pe1,CountBars,0,i);
//Buf1[i]=iCustom(NULL,0,"J_TPO",Pe2,CountBars,0,i);
//Buf[i]=iCustom(NULL,0,"rsx",Pe1,0,i);
//Buf1[i]=iCustom(NULL,0,"rsx",Pe2,0,i);
Buf2[i]=(Buf[i]+Buf1[i])/2;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments