0
Views
0
Downloads
0
Favorites
ChartInfo
//+------------------------------------------------------------------+
//| ChartInfo.mq5 |
//| Copyright © 2011, Nikolay Kositsin |
//| Khabarovsk, farria@mail.redcom.ru |
//+------------------------------------------------------------------+
//---- author of the indicator
#property copyright "Copyright © 2011, Nikolay Kositsin"
//---- link to the website of the author
#property link "farria@mail.redcom.ru"
//---- indicator version
#property version "1.00"
#property description "The indicator displays the line contents in one corner of the chart"
//---- drawing the indicator in the main window
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//+----------------------------------------------+
// type_font enumeration description |
// CFontName class description |
//+----------------------------------------------+
#include <GetFontName.mqh>
//+----------------------------------------------+
//| Indicator input parameters |
//+----------------------------------------------+
input string Text="Real"; // Text label contents
input color TextColor=Red; // Text label color
input int FontSize=24; // Font size
input type_font FontType=Font7; // Font type
input ENUM_BASE_CORNER WhatCorner=CORNER_LEFT_LOWER; // Location corner
input uint Y_=1; // Vertical location
//+----------------------------------------------+
string sFontType;
//+------------------------------------------------------------------+
//| Creation of a text label |
//+------------------------------------------------------------------+
void CreateTLabel(long chart_id, // chart ID
string name, // object name
int nwin, // window index
ENUM_BASE_CORNER corner, // base corner location
ENUM_ANCHOR_POINT point, // anchor point location
int X, // the distance from the base corner along the X-axis in pixels
int Y, // the distance from the base corner along the Y-axis in pixels
string text, // text
color Color, // text color
string Font, // text font
int Size) // font size
{
//----
ObjectCreate(chart_id,name,OBJ_LABEL,0,0,0);
ObjectSetInteger(chart_id,name,OBJPROP_CORNER,corner);
ObjectSetInteger(chart_id,name,OBJPROP_ANCHOR,point);
ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,X);
ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,Y);
ObjectSetString(chart_id,name,OBJPROP_TEXT,text);
ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);
ObjectSetString(chart_id,name,OBJPROP_FONT,Font);
ObjectSetInteger(chart_id,name,OBJPROP_FONTSIZE,Size);
ObjectSetInteger(chart_id,name,OBJPROP_BACK,true);
//----
}
//+------------------------------------------------------------------+
//| Text label reinstallation |
//+------------------------------------------------------------------+
void SetTLabel(long chart_id, // chart ID
string name, // object name
int nwin, // window index
ENUM_BASE_CORNER corner, // base corner location
ENUM_ANCHOR_POINT point, // anchor point location
int X, // the distance from the base corner along the X-axis in pixels
int Y, // the distance from the base corner along the Y-axis in pixels
string text, // text
color Color, // text color
string Font, // text font
int Size) // font size
{
//----
if(ObjectFind(chart_id,name)==-1)
{
CreateTLabel(chart_id,name,nwin,corner,point,X,Y,text,Color,Font,Size);
}
else
{
ObjectSetString(chart_id,name,OBJPROP_TEXT,text);
ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,X);
ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,Y);
ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);
}
//----
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//----
CFontName FONT;
sFontType=FONT.GetFontName(FontType);
//----
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//----
ObjectDelete(0,"Info_Label");
//----
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, // number of bars in history at the current tick
const int prev_calculated,// amount of history in bars at the previous tick
const datetime &time[],
const double &open[],
const double& high[], // price array of maximums of price for the calculation of indicator
const double& low[], // price array of minimums of price for the calculation of indicator
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//----
if(rates_total==prev_calculated) return(rates_total);
SetTLabel(0,"Info_Label",0,WhatCorner,ENUM_ANCHOR_POINT(2*WhatCorner),5,Y_,Text,TextColor,sFontType,FontSize);
//----
ChartRedraw(0);
//----
return(rates_total);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---