0
Views
0
Downloads
0
Favorites
a_candle
//+------------------------------------------------------------------+
//| CandleTime.mq4 |
//| Copyright © 2010, Elmare |
//| http://elmare.webnode.ru |
//+------------------------------------------------------------------+
#property copyright "Elmare © 2010"
#property link "http://elmare.webnode.ru/"
#property indicator_chart_window
//int per;
int tmp;
int sec;
int min;
int hor;
int barTime;
int curTime;
string cTime;
string sHor;
string sMin;
string sSec;
int per;
string sper;
extern int obCorner=3; // 0 - left up 3 - bottom right
extern int fsize=10; // font size
int init()
{
per=Period();
if (per<60){sper="M"+per;}
else if(per>=60&&per<60*24) {sper="H"+per/60+" ";}
else {sper="D"+per/(60*24);}
ObjectCreate("TimeLable12",OBJ_LABEL,0,0,0);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("TimeLable12");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// int counted_bars=IndicatorCounted();
per=Period();
barTime=Time[0];
curTime=TimeCurrent();
tmp=curTime-barTime; //ñåêóíäû ñ ìîìåíòà îòêðûòèÿ ñâå÷è
tmp=per*60-tmp; //ñåêóíäû äî îêîí÷àíèÿ ñâå÷è
// {
min=tmp/60;
hor=min/60;
min=min-hor*60;
sec=tmp-min*60-hor*60*60;
// }
if (min<10){sMin="0"+min;}
else {sMin=""+min;}
if (sec==60) {sec=59;}
if (sec<10){sSec="0"+sec;}
else {sSec=""+sec;}
if(hor>0)
{
if (hor<10){sHor="0"+hor;}
else {sHor=""+hor;}
}
if (hor==0) {
cTime=sMin+":"+sSec;
}
else {cTime=sHor+":"+sMin+":"+sSec;}
//----
ObjectSet("TimeLable12",OBJPROP_CORNER,obCorner);
ObjectSetText("TimeLable12",cTime,fsize,"Microsoft Sans Serif",Yellow);
ObjectSet("TimeLable12",OBJPROP_XDISTANCE,5);
ObjectSet("TimeLable12",OBJPROP_YDISTANCE,3);
//----
return(0);
}
//+------------------------------------------------------------------+
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
---