58 lines
5.1 KiB
MQL5
58 lines
5.1 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| ChartUtils.mqh |
|
|
//| Copyright 2021, MetaQuotes Ltd. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2021, MetaQuotes Ltd."
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
class ChartUtils {
|
|
private:
|
|
|
|
public:
|
|
ChartUtils();
|
|
~ChartUtils();
|
|
void setChartTemplate() {
|
|
ChartSetInteger(0,CHART_COLOR_BACKGROUND,0);
|
|
ChartSetInteger(0, CHART_FOREGROUND,16777215);
|
|
ChartSetInteger(0,CHART_COLOR_CHART_UP,7451452);
|
|
ChartSetInteger(0,CHART_COLOR_CHART_DOWN,255);
|
|
ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,7451452);
|
|
ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,255);
|
|
ChartSetInteger(0,CHART_COLOR_CHART_LINE,65280);
|
|
ChartSetInteger(0,CHART_COLOR_GRID,2697513);
|
|
|
|
ChartSetInteger(0,CHART_SHIFT,1);
|
|
ChartSetInteger(0,CHART_SHOW_ASK_LINE,1);
|
|
ChartSetInteger(0,CHART_SHOW_BID_LINE,1);
|
|
ChartSetInteger(0,CHART_SHOW_LAST_LINE,1);
|
|
ChartSetInteger(0,CHART_SHOW_PERIOD_SEP,1);
|
|
}
|
|
void drawLine(string name,datetime time1,double price1,datetime time2,double price2) {
|
|
//--- anulamos el valor del error
|
|
ResetLastError();
|
|
//--- creamos la línea de tendencia según las coordenadas establecidas
|
|
if(!ObjectCreate(0, name,OBJ_TREND,0,time1,price1,time2,price2)) {
|
|
Print(__FUNCTION__,
|
|
": ¡Fallo al crear la línea de tendencia! Código del error = ",GetLastError());
|
|
return;
|
|
}
|
|
//--- establecemos el color de la línea
|
|
ObjectSetInteger(0, name,OBJPROP_COLOR,clrBlue);
|
|
//--- establecemos el estilo de visualización de la línea
|
|
ObjectSetInteger(0, name,OBJPROP_STYLE,STYLE_SOLID);
|
|
//--- establecemos el grosor de la línea
|
|
ObjectSetInteger(0, name,OBJPROP_WIDTH,1);
|
|
}
|
|
};
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
ChartUtils::ChartUtils() {
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
ChartUtils::~ChartUtils() {
|
|
}
|
|
//+------------------------------------------------------------------+
|