i_daydemarker_v1_1

Download script
Author: ExcStrategy
i_daydemarker_v1_1

This script is designed as a custom technical analysis tool for MetaTrader 4, specifically used to measure and visualize market momentum. It calculates the DeMarker, which is an indicator that helps traders understand whether a market is trending strongly or simply moving sideways (ranging).

Core Functionality

The primary goal of this tool is to determine the "strength" of price movements over a specific period. Unlike some indicators that look at the raw price, this script analyzes the relationship between the high and low points of price candles to gauge how much "effort" is being put into a move compared to the actual distance traveled.

Key Logical Components

1. Dynamic Timeframe Validation Before performing any calculations, the script checks the chart's timeframe. It includes a safety mechanism that prevents the tool from running on high-level timeframes (anything larger than one day). If a user tries to apply it to a weekly or monthly chart, the script will issue an alert to ensure the data remains accurate and relevant.

2. Custom Calculation Period The logic utilizes a user-defined setting that dictates how many days of historical data should be analyzed. This allows you to adjust the "sensitivity" of the indicator—shortening the period for faster reactions or lengthening it to observe broader market trends.

3. Intelligent Bar Counting One of the most sophisticated parts of this script is how it identifies the number of candles to include in its calculation. Instead of simply taking a fixed number of bars, the logic automatically scans backward from the current price point. It counts the bars specifically within the desired time window, ensuring that the indicator correctly accounts for different chart types (such as 1-minute, 1-hour, or 4-hour charts) while remaining consistent with the actual calendar days.

4. DeMarker Calculation and Visualization Once the correct number of bars is identified based on your settings, the script performs the DeMarker calculation. It produces a line graph displayed in a separate window at the bottom of your screen. This line moves between the values of 0 and 1:

  • High Values (Approaching 1): Suggest that the market is showing strong bullish momentum.
  • Low Values (Approaching 0): Suggest that the market is showing strong bearish momentum.
  • Mid-Range Values: Help identify "choppy" or sideways markets where there is no clear direction.

Summary for the User

Essentially, this script automates the complex math of counting daily price movements into a simple visual line. It tells you at a glance whether the current market trend has enough "energy" to continue or if the price movement is becoming exhausted, helping you make more informed decisions on when to enter or exit a trade.

Indicators Used
DeMarker indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
19 Views
0 Downloads
0 Favorites
i_daydemarker_v1_1
//+------------------------------------------------------------------+
//|                                                  DayDeMarker.mq4 |
//|                                 Copyright 2010-2015, Excstrategy |
//|                                        http://www.ExcStrategy.ru |
//+------------------------------------------------------------------+
#property copyright "ExcStrategy"
#property link      "http://www.ExcStrategy.ru"
#property version   "1.1"
#property description "DeMarker"
#property strict
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 1 
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_level1     0.0
#property indicator_level2     0.7
#property indicator_level3     0.3
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT 
//----
extern int DaysForCalculation=2;
//---- buffers
double Buffer1[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(1);
//---- indicator lines
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffer1);
//---- 
   SetIndexLabel(0,"DeMarker");
//---
   DaysForCalculation=DaysForCalculation+1;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   if(Period()>1400)
     {
      Alert("Error! Period can not be greater than D1");
      return(0);
     }
//----
   int counted_bars=IndicatorCounted();
   int barsday;
   bool rangeday;
   datetime Time1=Time[0],Time2;
//----
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
//----
   for(int i=0; i<limit; i++)
     {
      //----
      rangeday= false;
      barsday = 0;
      //----
      Time2=Time[i]+(1440*60*DaysForCalculation);
      if(Time1<Time2)
         if(i<Bars-MathRound(1500/Period()))
            for(int a=i; a<i+1441; a++)
              {
               //----
               barsday++;
               //----
               if(TimeDayOfYear(Time[a])!=TimeDayOfYear(Time[a+1])) a=i+1442;
              }
      //----
      Buffer1[i]=iDeMarker(NULL,0,barsday,i);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments