CandleCountdown_v1

Author: Abraão Moreira
0 Views
0 Downloads
0 Favorites
CandleCountdown_v1
ÿþ//+------------------------------------------------------------------+

//|                                                  SimpleClock.mq5 |

//|                                                   Abraão Moreira |

//|                                      abraaol.moreira@outlook.com |

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

#property copyright "Abraão Moreira"

#property link      "abraaol.moreira@outlook.com"

#property version   "1.02"

#property indicator_chart_window



input color colorClock = clrGray; //Cor do relógio

input string font = "Arial";  //Fonte

input int fontSize = 10;  //Tamanho da fonte

enum style {

  comment = 0,      //Comment

  bigNumber = 1,    //Big number

  onPrice = 2,      //On Price    

};

input style swapStyle = comment;  //Tipo de exibição



ENUM_BASE_CORNER cornerBN = CORNER_RIGHT_UPPER;

ENUM_ANCHOR_POINT AnchorBN = ANCHOR_RIGHT_UPPER;

ENUM_ANCHOR_POINT AnchorOP = ANCHOR_LEFT;



int offsetX = 50;

int offsetY = 10;

string objName = "clock";

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

//| Custom indicator initialization function                         |

//| Create a label object                                            |

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

int OnInit() {

  

  return(INIT_SUCCEEDED);

}

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

//| 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[]) {

  ArraySetAsSeries(time, true);

  ArraySetAsSeries(close, true);

  string toShow;

  toShow = TimeToString(time[0]+PeriodSeconds()-TimeCurrent(), TIME_SECONDS);

  if(swapStyle == comment){

    Comment(toShow);

  }else{

    if(swapStyle == bigNumber){

      ObjectCreate(0, objName, OBJ_LABEL, 0, 0, 0);

      ObjectSetInteger(0, objName, OBJPROP_COLOR, colorClock);

      ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, fontSize);

      ObjectSetString(0, objName, OBJPROP_FONT, font);

      ObjectSetInteger(0, objName, OBJPROP_CORNER, cornerBN);

      ObjectSetInteger(0, objName, OBJPROP_XDISTANCE, 10);

      ObjectSetInteger(0, objName, OBJPROP_YDISTANCE, 2);

      ObjectSetInteger(0, objName, OBJPROP_ANCHOR, AnchorBN);

      ObjectSetString(0, objName, OBJPROP_TEXT, 0, toShow);

    }else{

      if(swapStyle == onPrice){

        toShow = "<-"+toShow;

        if(ObjectFind(0, objName) < 0){

          ObjectCreate(0, objName, OBJ_TEXT, 0, time[0]+offsetX, close[0]+offsetY);

          ObjectSetInteger(0, objName, OBJPROP_COLOR, colorClock);

          ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, fontSize);

          ObjectSetString(0, objName, OBJPROP_FONT, font);

          ObjectSetInteger(0, objName, OBJPROP_ANCHOR, AnchorOP);

          ObjectSetString(0, objName, OBJPROP_TEXT, 0, toShow); 

        }else{

          ObjectMove(0, objName, 0, time[0]+offsetX, close[0]+offsetY);

          ObjectSetString(0, objName, OBJPROP_TEXT, 0, toShow); 

        }  

      }

    }

  }

  return(rates_total);

}



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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam) {

//---



}

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

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