cm H V levels

Download script
Author: Copyright 2017, cmillion@narod.ru

This script is designed for the MetaTrader trading platform to automatically generate visual markers on your trading charts. It helps traders identify specific price levels and historical timeframes by drawing a grid of horizontal and vertical lines based on user-defined settings.

Core Functionality

The script operates by performing two primary visual tasks:

1. Horizontal Price Grid The tool identifies the current market price (the "Bid" price) and uses it as an anchor point. From this price, it calculates a series of specific price increments based on the "Point" value you choose in the settings.

  • It automatically draws multiple horizontal lines both above and below the current price.
  • This creates a visual "ladder" or grid, allowing you to see significant price levels at a glance without having to manually plot them.

2. Vertical Time Markers The script can also be configured to mark specific time intervals on your chart.

  • It looks back through historical data based on the timeframe selected in the settings (e.g., H1, M15, D1).
  • It places vertical lines at consistent intervals across the history of the chart.
  • This helps in identifying the start times of previous candles or periods, providing a clearer sense of time progression on the screen.

Customization Options

Users can personalize the appearance and behavior of these markers through several settings:

  • Point Value: You can define the distance between each horizontal line (e.g., how many pips or points apart they should be).
  • Timeframe: You can choose which historical time intervals the vertical lines should represent.
  • Visual Style: The script allows you to customize the thickness, line style (such as solid or dashed), and color of the markings so they fit your specific chart aesthetic.

How it Works Automatically

Whenever the script is activated, it first clears any existing objects it created to ensure the chart stays clean. It then instantly populates the screen with the requested grid of lines. Because it uses "Horizontal" (HLine) and "Vertical" (VLine) objects, these markers remain fixed in their respective positions as new price data flows into the platform.

11 Views
0 Downloads
0 Favorites
cm H V levels
ÿþ//+------------------------------------------------------------------+

#property copyright "Copyright 2017, cmillion@narod.ru"

#property link      "http://cmillion.ru"

#property version   "2.00"

#property show_inputs

#property strict

//+------------------------------------------------------------------+

enum tf 

{

   t1=0,     // =5B @07<5B:8 

   t5=5,     // M5

   t15=15,    // M15

   t30=30,    // M30

   t60=60,    // H1

   t240=240,   // H4

   t1440=1440,  // D1

};

enum pr 

{

   d0=0,     // =5B @07<5B:8 

   d1=1,     // 45AOBK5 

   d2=2,     // A>BK5

   d3=3,     // BKAOG=K5

};

input  pr      point    = d1;       //48A:@5B=>ABL @07<5B:8 ?> F5=5 (0->B:;)

input  tf      tfcandle = 60;       //?5@8>4 @07<5B:8 ?> 2@5<5=8

extern int     with     = 1;        //B>;I8=0  

extern ENUM_LINE_STYLE   style    = 0;        //AB8;L  

extern color   colr     = clrGray;  //F25B   

//+------------------------------------------------------------------+

void OnStart()

{

   ObjectsDeleteAll(0);

   if(point!=0)

   {

      double level=NormalizeDouble(Bid,Digits-point);

      drawhline(level);

      for (int i=0; i<1000; i++)

      { 

         drawhline(NormalizeDouble(level+point*10*Point*i ,Digits));

         drawhline(NormalizeDouble(level-point*10*Point*i ,Digits));

      }

   }   

   if(tfcandle!=0)

   {

      for (int i=0; i<1000; i++)

      { 

         drawvline(iTime(NULL,tfcandle,i));

      }

   }   

}

//+------------------------------------------------------------------+

void drawhline(double level)

{

   string name = StringConcatenate("Level_",level);

   if (ObjectFind(name)!=-1) ObjectDelete(name);

   ObjectCreate(name, OBJ_HLINE, 0, 0, level, 0,0);

   ObjectSet   (name, OBJPROP_COLOR, colr);

   ObjectSet   (name, OBJPROP_WIDTH,with);

   ObjectSet   (name, OBJPROP_STYLE,style);

}   

//--------------------------------------------------------------------

void drawvline(datetime time)

{

   string name = TimeToStr(time);

   if (ObjectFind(name)!=-1) ObjectDelete(name);

   ObjectCreate(name, OBJ_VLINE, 0, time, 0, 0,0);

   ObjectSet   (name, OBJPROP_COLOR, colr);

   ObjectSet   (name, OBJPROP_WIDTH,with);

   ObjectSet   (name, OBJPROP_STYLE,style);

}   

//--------------------------------------------------------------------

Comments