StepChoppy_v1
Download scriptThis script is a specialized visual tool designed to help traders identify the current state of a market trend by categorizing price movements into eight distinct "moods" or phases. Instead of just telling you if the price is going up or down, it breaks down the quality and momentum of those movements, providing a more nuanced view of market behavior.
How the Logic Works
The script functions by analyzing three primary layers of data: Moving Averages (which define the overall trend direction), a standard Relative Strength Index (RSI), and two different "Step" versions of the RSI that move at different speeds (Fast and Slow).
By comparing these values against each other, the script classifies the market into two main categories—Upward Trends and Downward Trends—each subdivided into four specific stages:
1. Upward Trend Analysis
When the underlying data confirms an upward bias, the script visualizes four different states:
- Strong UpTrend: Indicates high-momentum bullish movement where the price is moving aggressively in one direction.
- Retrace UpTrend: Suggests a momentary pullback or "breather" during a larger move upward; the trend is still there, but it is cooling off.
- Choppy UpTrend: Signals that while the overall bias is up, the price action is becoming disorganized or inconsistent.
- Ready to Change: A warning state indicating that the current upward momentum is fading and a reversal or significant shift may be imminent.
2. Downward Trend Analysis
When the underlying data confirms a downward bias, the script mirrors this logic:
- Strong DownTrend: Indicates high-momentum bearish movement.
- Retrace DownTrend: Suggests a temporary recovery or "bounce" during a larger move down.
- Choppy DownTrend: Signals disorganized price action with an underlying bearish bias.
- Ready to Change: A warning state indicating that the downward momentum is losing steam and a shift in direction might occur soon.
Visual Representation
The script outputs these findings as a color-coded histogram in a separate window on your chart. The colors act as a visual shorthand:
- Cooler Colors (Blues/Aquas): Represent various stages of an Upward Trend.
- Warmer Colors (Reds/Yellows/Oranges): Represent various stages of a Downward Trend.
Summary for the User
Essentially, this tool acts as a "market mood ring." It helps you distinguish between a healthy, strong trend and a tired, "choppy," or exhausting market. By identifying when a trend is becoming "choppy" or is "ready to change," it aims to provide traders with better context on when to stay the course and when to be cautious about entering new positions.
//+------------------------------------------------------------------+
//| StepChoppy_v1.mq4 |
//| Copyright © 2006, Forex-TSD.com |
//| Written by IgorAD,igorad2003@yahoo.co.uk |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link "http://www.forex-tsd.com/"
#property indicator_separate_window
#property indicator_minimum -0.05
#property indicator_maximum 1.05
#property indicator_buffers 8
//---- input parameters
int Length=10;
double StepSizeFast=5;
double StepSizeSlow=15;
int MAPeriod=1;
int Price=0;
int Mode=2;
//---- buffers
double UpBuffer1[];
double UpBuffer2[];
double UpBuffer3[];
double UpBuffer4[];
double DnBuffer1[];
double DnBuffer2[];
double DnBuffer3[];
double DnBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//----
SetIndexStyle(0,DRAW_HISTOGRAM,0,3,Blue);
SetIndexStyle(1,DRAW_HISTOGRAM,0,3,DodgerBlue);
SetIndexStyle(2,DRAW_HISTOGRAM,0,3,LightBlue);
SetIndexStyle(3,DRAW_HISTOGRAM,0,3,Aqua);
SetIndexStyle(4,DRAW_HISTOGRAM,0,3,Red);
SetIndexStyle(5,DRAW_HISTOGRAM,0,3,Tomato);
SetIndexStyle(6,DRAW_HISTOGRAM,0,3,Orange);
SetIndexStyle(7,DRAW_HISTOGRAM,0,3,Yellow);
SetIndexBuffer(0,UpBuffer1);
SetIndexBuffer(1,UpBuffer2);
SetIndexBuffer(2,UpBuffer3);
SetIndexBuffer(3,UpBuffer4);
SetIndexBuffer(4,DnBuffer1);
SetIndexBuffer(5,DnBuffer2);
SetIndexBuffer(6,DnBuffer3);
SetIndexBuffer(7,DnBuffer4);
//----
short_name="StepChoppy";
IndicatorShortName(short_name);
SetIndexLabel(0,"Strong UpTrend");
SetIndexLabel(1,"Retrace UpTrend");
SetIndexLabel(2,"Choppy UpTrend");
SetIndexLabel(3,"Be ready to change UpTrend");
SetIndexLabel(4,"Strong DownTrend");
SetIndexLabel(5,"Retrace DownTrend");
SetIndexLabel(6,"Choppy DownTrend");
SetIndexLabel(7,"Be ready to change DownTrend");
//----
SetIndexDrawBegin(0,Length);
SetIndexDrawBegin(1,Length);
SetIndexDrawBegin(2,Length);
SetIndexDrawBegin(3,Length);
SetIndexDrawBegin(4,Length);
SetIndexDrawBegin(5,Length);
SetIndexDrawBegin(6,Length);
SetIndexDrawBegin(7,Length);
//----
return(0);
}
//+------------------------------------------------------------------+
//| StepRSIFilter_v1 |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double RSI, FastRSI, SlowRSI, StepMA, MA,UpTrendMA, DnTrendMA;
//----
if(Bars<=Length) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=Length;i++)
{
UpBuffer1[Bars-i]=0.0;
UpBuffer2[Bars-i]=0.0;
UpBuffer3[Bars-i]=0.0;
UpBuffer4[Bars-i]=0.0;
DnBuffer1[Bars-i]=0.0;
DnBuffer2[Bars-i]=0.0;
DnBuffer3[Bars-i]=0.0;
DnBuffer4[Bars-i]=0.0;
}
//----
if ( counted_bars > 0 ) int limit=Bars-counted_bars;
if ( counted_bars ==0 ) limit=Bars-Length-1;
for(i=limit;i>=0;i--)
{
UpTrendMA = iCustom(NULL,0,"StepMA_v7",Length,1.0,0,0,0,0,true,2,0,1,i);
DnTrendMA = iCustom(NULL,0,"StepMA_v7",Length,1.0,0,0,0,0,true,2,0,2,i);
RSI=iCustom(NULL,0,"StepRSI_v5.2",Length,StepSizeFast,MAPeriod,Price,Mode,0,i);
FastRSI=iCustom(NULL,0,"StepRSI_v5.2",Length,StepSizeFast,MAPeriod,Price,Mode,1,i);
SlowRSI=iCustom(NULL,0,"StepRSI_v5.2",Length,StepSizeSlow,MAPeriod,Price,Mode,1,i);
if (FastRSI > SlowRSI && RSI > FastRSI && UpTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 1.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 0.0;}
else if (FastRSI > SlowRSI && RSI < FastRSI && UpTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 1.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 0.0;}
else if (FastRSI < SlowRSI && RSI > FastRSI && UpTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 1.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 0.0;}
else if (FastRSI < SlowRSI && RSI < FastRSI && UpTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 1.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 0.0;}
else if (FastRSI < SlowRSI && RSI < FastRSI && DnTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 1.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 0.0;}
else if (FastRSI < SlowRSI && RSI > FastRSI && DnTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 1.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 0.0;}
else if (FastRSI > SlowRSI && RSI < FastRSI && DnTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 1.0;DnBuffer4[i] = 0.0;}
else if (FastRSI > SlowRSI && RSI > FastRSI && DnTrendMA!=EMPTY_VALUE)
{UpBuffer1[i] = 0.0;UpBuffer2[i] = 0.0;UpBuffer3[i] = 0.0;UpBuffer4[i] = 0.0;
DnBuffer1[i] = 0.0;DnBuffer2[i] = 0.0;DnBuffer3[i] = 0.0;DnBuffer4[i] = 1.0;}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments