Double-Zero

Download script
Double-Zero

Overview

The Double-Zero-Visualizer is a specialized charting tool designed to help traders identify significant "round numbers" on a price chart. In many financial markets, prices often react psychologically at levels where digits become zeros (e.g., 1.2000 instead of 1.2345). This script automatically calculates and draws these milestones based on a specific decimal position you choose to prioritize.

How It Works

The core logic of this tool revolves around "rounding" the current market price to the nearest significant zero. Instead of showing every tiny fluctuation in price, it simplifies the data into larger, cleaner increments.

You can control exactly which digit the script focuses on using the Relevant Digit Position setting. The logic follows these steps:

  1. Price Input: The script looks at the closing price of the market at any given time.
  2. Decimal Targeting: Based on the position you select, the script identifies the specific "place value" in that price (for example, the second decimal place, the third decimal place, or even a whole number).
  3. Rounding Logic: It mathematically shifts the price to the nearest multiple of that digit, effectively turning everything to the right of your chosen position into zeros.
  4. Visual Representation: The script then draws a continuous line on your chart representing these "Double-Zero" levels.

Practical Examples

To understand how the logic adapts to different markets and preferences, consider these scenarios:

  • Standard Forex (4 Digits): If you set the position to 2 on a price of 1.2312, the tool ignores the last two digits and visualizes the level as 1.2300.
  • High Precision (5 Digits): If you set the position to 3 on a price of 1.23125, the tool treats the third decimal as the anchor, visualizing it as 1.23100.
  • Major Milestones: If you set the position to 1 on a price of 1.23125, it rounds down significantly to show you the major move at 1.20000.
  • Whole Numbers: In markets with fewer decimal places (like some commodities), using a negative number like -1 would allow you to visualize the nearest whole number (e.g., rounding 123.15 to 120.00).

Summary for Traders

This tool is essentially a "cleaner" for your chart. It removes the noise of minor price fluctuations and highlights the structural levels where prices are mathematically rounded. By visualizing these zeros, it helps you identify potential areas of support, resistance, or psychological turning points more clearly.

Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Double-Zero
//+------------------------------------------------------------------+
//|                                            Double-Zero-Visualizer|
//+------------------------------------------------------------------+

#property  copyright "ps"
#property  link      ""
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  Lime
#property  indicator_width1  1

//---- indicator parameters
extern int relDigitPos=2;  // position of the relevant digit. 
                      // example1: a setting of "2"  in a market at the level of 1,2312  (taxed by 4 digits) makes the indicator visualize 1,2300
                      // example2: a setting of "3"  in a market at the level of 1,23125 (taxed by 5 digits) makes the indicator visualize 1,23100
                      // example3: a setting of "1"  in a market at the level of 1,23125 (taxed by 5 digits) makes the indicator visualize 1,20000
                      // example4: a setting of "-1" in a market at the level of 123,15  (taxed by 2 digits) makes the indicator visualize 120,00

//---- indicator 
double buf[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   
//---- indicator buffers mapping
   SetIndexBuffer(0,buf);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Double-Zero-Visualizer");
   SetIndexLabel(0,"Nearest Double-Zero");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| now do the dance.                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

//---- calculate values
   for(int i=0; i<limit; i++) {
      buf[i]=getNearestDoubleZero(iClose(Symbol(),PERIOD_M1,i*Period()),relDigitPos);
   }
   
   return(0);
  }

double getNearestDoubleZero(double price, int pos) {
   double factor=MathPow(10, pos);
   return(MathRound(price*factor)/factor);
}

Comments