candle_time_end_and_spread

candle_time_end_and_spread
Price Data Components
Series array that contains open time of each bar
0 Views
0 Downloads
0 Favorites
candle_time_end_and_spread
//+------------------------------------------------------------------+
//|                                          CandleTimeStationary.mq4|
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
//---- input parameters

extern color  Clock_Color = DimGray;
extern string Corner_Placement = "1 is top right 3 is bottom right";
extern int    Corner = 3;


string objname="Spread&Bar";
double s1[];

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init(){

  ObjectCreate(objname, OBJ_LABEL,0, 0, 0);
  ObjectSet(objname, OBJPROP_CORNER, Corner);
  ObjectSet(objname, OBJPROP_XDISTANCE, 10);
  ObjectSet(objname, OBJPROP_YDISTANCE, 2);     
   
   //----
   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit(){

  ObjectDelete(objname);

  //----
  return(0);
} 


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{

   //Time to bar expiry
  int m,s;

  m=Time[0]+Period()*60-CurTime();
  s=m%60;
  m=(m-s)/60;
  int spread=MarketInfo(Symbol(), MODE_SPREAD);

  string _sp="",_m="",_s="";
  if (spread<10) _sp="..";
  else if (spread<100) _sp=".";
  if (m<10) _m="0";
  if (s<10) _s="0";
  
  ObjectSetText(objname,"Spread: " +DoubleToStr(spread,0)+_sp+" Next Bar in "+_m+DoubleToStr(m,0)+":"+_s+DoubleToStr(s,0), 10, "Courier", Clock_Color);
  return(0);
}
//+---------------------------------------------------------

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---