StepSto_v1_v1
Download scriptThis technical indicator, known as the StepSto, is designed to help traders visualize market trends and price momentum by identifying "steps" in price movement. Unlike standard oscillators that simply follow price changes, this tool calculates specific boundaries to determine if the market is trending upward, downward, or staying within a neutral zone.
Core Logic and Mechanism
The script operates by analyzing three distinct layers of market sensitivity simultaneously. It achieves this by calculating three different "step sizes" based on recent market volatility (measured via the Average True Range). These three levels are categorized as follows:
- Minimum Sensitivity: Captures smaller, more frequent price movements.
- Maximum Sensitivity: Focuses on larger, more significant price swings.
- Mid-Range Sensitivity: A balanced middle ground between the two extremes.
How it Determines Trends
For each of these three sensitivities, the script establishes a "boundary" around the current price. It looks at where the price closed in relation to these boundaries:
- Trend Detection: The tool constantly checks if the current price has broken above or below the boundaries set by the previous candle. If it breaks out, the script identifies a trend (positive for an uptrend, negative for a downtrend).
- Memory Effect: A key feature of this logic is its "memory." Once a trend is established, the indicator maintains that direction until a significant price reversal occurs. It keeps track of the lowest or highest boundaries reached during that trend to ensure the calculation remains consistent as time progresses.
- Dynamic Adjustment: Because it uses volatility as a base, the "steps" automatically expand when the market is volatile and shrink when the market becomes quiet.
Visual Output
The final result is presented in a separate window on your trading platform as two distinct lines:
- The Fast Line (Yellow): This represents the most reactive trend based on the minimum sensitivity settings. It responds quickly to minor price shifts.
- The Slow Line (DeepSkyBlue): This represents the balanced trend based on the mid-range sensitivity settings. It provides a smoother, more stabilized view of the market's direction.
By comparing these two lines, traders can see not just which way the price is moving, but how strongly it is moving and whether the current momentum is consistent across different levels of market volatility.
//+------------------------------------------------------------------+
//| StepSto_v1.mq4 |
//| Copyright © 2005, TrendLaboratory Ltd. |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
#property link "E-mail: igorad2004@list.ru"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 DeepSkyBlue
//---- input parameters
extern double Kfast=1.0000;
extern double Kslow=1.0000;
//---- indicator buffers
double LineFastBuffer[];
double LineSlowBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,LineFastBuffer);
SetIndexBuffer(1,LineSlowBuffer);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="StepSto("+Kfast+","+Kslow+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"StepSto Fast");
SetIndexLabel(1,"StepSto Slow");
//----
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
//----
return(0);
}
//+------------------------------------------------------------------+
//| StepSto_v1 |
//+------------------------------------------------------------------+
int start()
{
int shift,TrendMin,TrendMax,TrendMid;
double SminMin0,SmaxMin0,SminMin1,SmaxMin1,ATR0,ATRmax,ATRmin;
double SminMax0,SmaxMax0,SminMax1,SmaxMax1,SminMid0,SmaxMid0,SminMid1,SmaxMid1;
double linemin,linemax,linemid,Sto1,Sto2,bsmin,bsmax;
double PeriodATR=10;
for(shift=Bars-1-PeriodATR;shift>=0;shift--)
{
ATR0 = iATR(NULL,0,PeriodATR,shift);
ATRmax=MathMax(ATR0,ATRmax);
if (shift==Bars-1-PeriodATR) ATRmin=ATR0;
ATRmin=MathMin(ATR0,ATRmin);
double StepSizeMin=(Kfast*ATRmin);
double StepSizeMax=(Kfast*ATRmax);
double StepSizeMid=(Kfast*0.5*Kslow*(ATRmax+ATRmin));
SmaxMin0=Close[shift]+2*StepSizeMin;
SminMin0=Close[shift]-2*StepSizeMin;
SmaxMax0=Close[shift]+2*StepSizeMax;
SminMax0=Close[shift]-2*StepSizeMax;
SmaxMid0=Close[shift]+2*StepSizeMid;
SminMid0=Close[shift]-2*StepSizeMid;
if(Close[shift]>SmaxMin1) TrendMin=1;
if(Close[shift]<SminMin1) TrendMin=-1;
if(Close[shift]>SmaxMax1) TrendMax=1;
if(Close[shift]<SminMax1) TrendMax=-1;
if(Close[shift]>SmaxMid1) TrendMid=1;
if(Close[shift]<SminMid1) TrendMid=-1;
if(TrendMin>0 && SminMin0<SminMin1) SminMin0=SminMin1;
if(TrendMin<0 && SmaxMin0>SmaxMin1) SmaxMin0=SmaxMin1;
if(TrendMax>0 && SminMax0<SminMax1) SminMax0=SminMax1;
if(TrendMax<0 && SmaxMax0>SmaxMax1) SmaxMax0=SmaxMax1;
if(TrendMid>0 && SminMid0<SminMid1) SminMid0=SminMid1;
if(TrendMid<0 && SmaxMid0>SmaxMid1) SmaxMid0=SmaxMid1;
if (TrendMin>0) linemin=SminMin0+StepSizeMin;
if (TrendMin<0) linemin=SmaxMin0-StepSizeMin;
if (TrendMax>0) linemax=SminMax0+StepSizeMax;
if (TrendMax<0) linemax=SmaxMax0-StepSizeMax;
if (TrendMid>0) linemid=SminMid0+StepSizeMid;
if (TrendMid<0) linemid=SmaxMid0-StepSizeMid;
bsmin=linemax-StepSizeMax;
bsmax=linemax+StepSizeMax;
Sto1=(linemin-bsmin)/(bsmax-bsmin);
Sto2=(linemid-bsmin)/(bsmax-bsmin);
LineFastBuffer[shift]=Sto1*100;
LineSlowBuffer[shift]=Sto2*100;
SminMin1=SminMin0;
SmaxMin1=SmaxMin0;
SminMax1=SminMax0;
SmaxMax1=SmaxMax0;
SminMid1=SminMid0;
SmaxMid1=SmaxMid0;
}
return(0);
}
Comments