Cronex Demarker Bars

Download script
Cronex Demarker Bars

Overview of the Cronex DeMarker Bars Logic

The Cronex DeMarker Bars is a specialized technical analysis tool designed to help traders identify market momentum and direction. Instead of looking at price action alone, this script analyzes the "strength" of a trend by processing raw data through several layers of calculation to determine if the market is moving up, down, or remains neutral.

How the Logic Works

The script operates through three primary stages:

1. Momentum Foundation (The DeMarker Base) The core of the tool starts with the DeMarker indicator. This provides a base reading of market momentum. Rather than using the raw momentum value as a final signal, the script uses it as the primary data source for further calculations.

2. Trend Filtering (Moving Averages) To smooth out "noise" and prevent false signals, the script applies two different types of Moving Averages (Fast and Slow) specifically to the DeMarker data mentioned above:

  • Fast Moving Average: Reacts quickly to recent changes in momentum.
  • Slow Moving Average: Provides a broader view of the underlying momentum trend.

By comparing the current DeMarker value against these two averages, the script creates a more stable environment for identifying clear market shifts.

3. Signal Identification (The Trend Logic) The script evaluates the relationship between the DeMarker value, the Fast average, and the Slow average to categorize the market into one of three states:

  • Bullish (Up): When the momentum is high and consistently trending above both moving averages, the script identifies an "Up" signal.
  • Bearish (Down): When the momentum is low and consistently trending below both moving averages, the script identifies a "Down" signal.
  • Neutral (Equal/Side-ways): If the values do not meet the specific criteria for either an upward or downward trend, the script identifies the market as neutral.

Visual and Audible Alerts

The tool translates these mathematical calculations into easy-to-read visual cues:

  • Histograms: The script paints different colors on your chart to represent these states (Up, Down, or Neutral) so you can see the trend at a glance.
  • Real-Time Notifications: The logic includes a notification system that monitors for new trend shifts. If a trend changes, the user can opt to receive:
    • Pop-up Alerts: Visual notifications on the platform showing the current price and timeframe.
    • Audio Cues: Sound files that play automatically to notify you of a momentum shift without needing to watch the screen constantly.

Summary for the User

Essentially, this script acts as a filter. It takes raw market momentum, smooths it out using multiple averages to eliminate "fake" movements, and then clearly labels the current market condition as a buy-leaning trend, a sell-leaning trend, or a neutral zone.

Indicators Used
DeMarker indicatorMoving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
16 Views
0 Downloads
0 Favorites
Cronex Demarker Bars
//+------------------------------------------------------------------+
//|                                         Cronex Demarker Bars.mq4 |
//|                                         Adapted by CJA           |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                              Cronex DeMarker.mq4 |
//|                                        Copyright © 2007, Cronex. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2007, Cronex"
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 6

#property  indicator_color4  DarkGreen
#property  indicator_color5  Maroon
#property  indicator_color6  DarkGoldenrod

#property  indicator_width4  2
#property  indicator_width5  2
#property  indicator_width6  2
//---- indicator parameters
extern int DeMarker=25;
extern int FastMA=14;
extern int SlowMA=25;

extern bool   AlertON = false;
extern bool   SoundON = false;
extern string SoundFile_UP = "Alert";
extern string SoundFile_DN = "Alert2"; 
//---- indicator buffers
double     DeMarkerBuffer[];
double     FastMABuffer[];
double     SlowMABuffer[];
double UpBuffer[];
double DnBuffer[];
double EqBuffer[];
int  TimeFrame;
string TF;
double trend;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_NONE);   
   SetIndexDrawBegin(1,SlowMA);
//   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,DeMarkerBuffer);
   SetIndexBuffer(1,FastMABuffer);
   SetIndexBuffer(2,SlowMABuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Cronex DeMarker Bars");
   SetIndexLabel(0,"");
   SetIndexLabel(1,"");
   SetIndexLabel(2,"");
   
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexStyle(5,DRAW_HISTOGRAM);
   
   SetIndexBuffer(3,UpBuffer);
   SetIndexBuffer(4,DnBuffer);
   SetIndexBuffer(5,EqBuffer);
   
   SetIndexLabel(3,"");
   SetIndexLabel(4,"");
   SetIndexLabel(5,"");
   
    	switch(TimeFrame)
	{
		case 1:		TF=" M1";  break;
		case 5:		TF=" M5";  break;
		case 15:		TF=" M15"; break;
		case 30:		TF=" M30"; break;
		case 60:		TF=" H1";  break;
		case 240:	TF=" H4";  break;
		case 1440:	TF=" D1";  break;
		case 10080:	TF=" W1";  break;
		case 43200:	TF=" MN1"; break;
		default:	  {TimeFrame = Period(); init(); return(0);}
	}
   
  
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Cronex DeMarker                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- DeMarker counted in the 1-st buffer

   for(int i=0; i<limit; i++)
      DeMarkerBuffer[i]=iDeMarker(NULL,0,DeMarker,i);
//---- signal line counted in the 2-nd buffer
   for(i=0; i<limit; i++)
    {  
      FastMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,FastMA,0,MODE_LWMA,i);
      SlowMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,SlowMA,0,MODE_LWMA,i);
     
     }
     for(i=0; i<limit; i++)
    {  
        
     if((FastMABuffer[i] > SlowMABuffer[i])&&(DeMarkerBuffer[i] > SlowMABuffer[i])&&(DeMarkerBuffer[i] > FastMABuffer[i])){trend=1;}
     else if((FastMABuffer[i] < SlowMABuffer[i])&&(DeMarkerBuffer[i] < SlowMABuffer[i])&&(DeMarkerBuffer[i] < FastMABuffer[i])){trend=-1;}
     else {trend=2;}
     
	  if (trend==1)
	  {
	  
	  UpBuffer[i]=1;
	  EqBuffer[i]=0;
	  DnBuffer[i]=0;
	  
	  
	  }
	  if (trend==2) 
	  {
	  
	  UpBuffer[i]=0;
	  EqBuffer[i]=1;
	  DnBuffer[i]=0;
	  
	  }
	  if (trend==-1) 
	  {
	    
	  UpBuffer[i]=0;
	  EqBuffer[i]=0;
	  DnBuffer[i]=1;
	 
	  }}
	  double Price = iMA(NULL,PERIOD_M1,1,0,MODE_SMA,PRICE_CLOSE,0);
	  static datetime timeprev;

     if(timeprev==Time[0]) {
     return(0); 
     } else if (timeprev==0) {
     timeprev=Time[0]; 
     return(0);
     } else {
     timeprev=Time[0];
  
   
	  if (trend==1)
	  if(AlertON){Alert(Symbol()+""+TF+" : DEM Bars X UP @ "+DoubleToStr(Price,Digits));}
     if (SoundON) PlaySound (SoundFile_UP);
     if (trend==-1)
     if(AlertON){Alert(Symbol()+""+TF+" : DEM Bars X DOWN @ "+DoubleToStr(Price,Digits));}       
     if (SoundON) PlaySound (SoundFile_DN);
	  }
	  
       
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments