CK_Speed
Download scriptOverview of the TrendJudge Logic
The TrendJudge tool is designed as a visual aid for traders to identify market conditions by analyzing price volatility and momentum. Rather than showing standard price movements, it processes complex mathematical data to categorize the current state of the market into three distinct zones: Trend, Correction, and Sleep.
How the Tool Works
The logic operates by calculating two specific types of market measurements simultaneously:
- Volatility Tracking: It monitors how much the price is "swinging" or fluctuating over a specific period.
- Standard Deviation Analysis: It measures how much the current price deviates from its average behavior.
The tool then applies a secondary layer of analysis (Relative Strength) to these two measurements. By checking where these values sit relative to a predefined threshold (the "Level"), the script determines which of the three states the market is currently in.
Market States Defined
The indicator visualizes these results as a histogram, allowing you to see the market's "mood" at a glance:
- Trend (Green): This state is triggered when both the volatility and the price deviation are high. It suggests that the market has strong momentum and is moving decisively in a specific direction.
- Sleep (Red): This state occurs when both volatility and price deviation are low. It indicates a "quiet" market where there is very little movement or interest, suggesting a period of stagnation or consolidation.
- Correction (Yellow): This is the middle ground. If one metric is high while the other is low, the tool identifies this as a correction. It suggests that while there is some activity, it lacks the consistency of a full trend, often signaling a transition or a temporary price adjustment.
Summary for the User
Essentially, this script filters out the "noise" of the market. Instead of forcing you to interpret messy price candles, it simplifies the data into a clear visual signal: it tells you when the market is moving with purpose (Trend), when it is resting (Sleep), or when it is in between (Correction).
//+------------------------------------------------------------------+
//| TrendJugde.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern int period=20;
extern double level=50;
//extern int ema1=34;
//extern int ema2=89;
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_maximum 3
bool uptrend=false;
bool downtrend=false;
double fast[],medium[],slow[],atr[],std[],rsistd[],rsiatr[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(7);
//---- drawing settings
SetIndexBuffer(0,fast);//bbMacd line
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(1,medium);//Upperband line
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexDrawBegin(0,period);
SetIndexDrawBegin(1,period);
SetIndexBuffer(2,slow);//overbough
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexDrawBegin(2,period);
SetIndexBuffer(3,atr);//overbough
SetIndexBuffer(4,std);//overbough
SetIndexBuffer(5,rsistd);//overbough
SetIndexBuffer(6,rsiatr);//overbough
IndicatorShortName("CK Speed "+ period);
SetIndexLabel(0,"Trend");
SetIndexLabel(1,"Correction");
SetIndexLabel(2,"Sleep");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
double prev,current,tmp;
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//uptrend=true;
//owntrend=true;
double filterbuy=60;
double filtersell=40;
//----
for(int k=limit-1;k>=0;k--){
atr[k]=iATR(Symbol(),0,period,k);
std[k]=iStdDev(Symbol(),0,period,0,0,PRICE_MEDIAN,k);
}
//for(int t=limit-period;t>=0;t--){
//}
for(int i=limit-1; i>=0; i--)
{
rsistd[i]=iRSIOnArray(std,0,period,i);
rsiatr[i]=iRSIOnArray(atr,0,period,i);
if(rsistd[i]>=level&&rsiatr[i]>=level){
fast[i]=3;
medium[i]=0;
slow[i]=0;
}else if(rsistd[i]<level&&rsiatr[i]<level){
fast[i]=0;
medium[i]=0;
slow[i]=1;
} else{
fast[i]=0;
medium[i]=2;
slow[i]=0;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments