Author: Copyright 2014, Andriy Ostafiychuk
0 Views
0 Downloads
0 Favorites
TLSS
#property strict

//+------------------------------------------------------------------+
//|                                                         TLSS.mq4 |
//|                               Copyright 2014, Andriy Ostafiychuk |
//|                       https://login.mql5.com/ru/users/geoscience |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Andriy Ostafiychuk"
#property link      "https://login.mql5.com/ru/users/geoscience"
#property version   "1.01"
#property indicator_chart_window

extern bool   Clock      = true;  //Show Clock?
extern bool   Leverage   = true;  //Show Leverage?
extern bool   Swap       = true;  //Show Swap?
extern bool   Spread     = true;  //Show Spread?
extern bool   Background = true;  //Show Background?
extern string FontType        = "Verdana";
extern int    FontSize        = 10;
extern color  Clock_Color     = Yellow;
extern color  General_text    = White;
extern color  Swap_Buy_Color  = Red;
extern color  Swap_Sell_Color = Gainsboro;
extern color  Background_Color = DarkSlateGray;
extern color  Background_Frame = Gainsboro;

datetime previousTime = 0;
int i;
//+------------------------------------------------------------------+
int OnInit()
{
   IndicatorShortName("TLSS "+Symbol());
   if(Background)
   {
      ObjectCreate(0,"TLSS_bg",OBJ_RECTANGLE_LABEL,0,0,0);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_XDISTANCE,5);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_YDISTANCE,20);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_YSIZE,90);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_XSIZE,150);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_BGCOLOR,Background_Color);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_BORDER_TYPE,BORDER_FLAT);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_COLOR,Background_Frame);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(0,"TLSS_bg",OBJPROP_WIDTH,1);
   }
   Sleep(100);
   if(Clock) Comment("", Clock_Color);
   if(Swap)
   {
      Comment("Buy Swap: ", DoubleToStr(MarketInfo(Symbol(),MODE_SWAPLONG),2));
      Comment("Sell Swap: ", DoubleToStr(MarketInfo(Symbol(),MODE_SWAPSHORT),2));
   }
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   int obj_total = ObjectsTotal();
   for(int obj = obj_total-1; obj >= 0; obj--)
   {
      string objname = ObjectName(obj);
      if(StringFind(objname, "TLSS") >= 0)
         ObjectDelete(objname);
   }
}
//+------------------------------------------------------------------+
//|  Custom indicator iteration function                             |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   if(Leverage) Comment("Leverage:  1:", IntegerToString(AccountLeverage()));
   if(Spread) Comment("Current spread: ", DoubleToStr(MarketInfo(Symbol(),MODE_SPREAD),0));
   return(rates_total);
}
//+------------------------------------------------------------------+
void OnTimer()
{
   datetime currentTime = TimeCurrent();
   if (currentTime - previousTime >= 1)
   {
      previousTime = currentTime;
      if(Clock) Comment("", Clock_Color);
   }
}
//+------------------------------------------------------------------+
//|  Output parameters in objects                                    |
//+------------------------------------------------------------------+
void Comment(string s0="",string s1="")
{
   string r = s0 + s1;
   string name = "TLSS_" + IntegerToString(i);
   int y = 25 + i * 15;
   int x = 10;
   if(ObjectFind(name) < 0) ObjectCreate(name,OBJ_LABEL,0,0,0);
   ObjectSet(name,OBJPROP_XDISTANCE,x);
   ObjectSet(name,OBJPROP_YDISTANCE,y);
   ObjectSetText(name,r,FontSize,FontType,General_text);
   i++;
}
//+------------------------------------------------------------------+

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 ---