operlay:
Добрый день.
Цвет фона графика.
ChartRedraw();
This is an English language forum.
Please only post in English
Use the sites translation function if necessary
Use the insert code button (Alt + S) when posting code.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Добрый день.
Цвет фона графика.
Код такой не работает корректно.
Функция Печать корректно выводится по таймеру.
А график меняет цвет только по тику.
Должна быть какая-то функция, которая обновляет график. Видимо она обновляется только при приходе тика.
Можете подсказать?
Код представлен ниже ..
//+------------------------------------------------------------------+
//| TimerColorGraph.mq4 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
EventSetMillisecondTimer(1000);
return(INIT_SUCCEEDED);
}
int OnDeinit()
{
////--- indicator buffers mapping
EventKillTimer();
return 0;
}
//+------------------------------------------------------------------+
//| 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 [])
{
// ---
// --- возвращаемое значение prev_calculated для следующего вызова
возвращать (rates_total);
}
// + ----------------------------------------------- ------------------- +
// | Функция таймера |
// + ----------------------------------------------- ------------------- +
void OnTimer ()
{
color currentColor;
currentColor = ChartBackColorGet (0);
Print ("Я тик с таймера до" + currentColor);
if (currentColor == clrRed) {
ChartBackColorSet (clrBlack, 0);
// Sleep (200);
вернуть;
}
if (currentColor == clrBlack) {
ChartBackColorSet (clrRed, 0);
// Sleep (200);
вернуть;
}
Print ("Я тик с таймера после" + currentColor);
}
void OnTick () {
}
// + ----------------------------------------------- ------------------- +
// + ----------------------------------------------- ------------------- +
// | Функция получает цвет фона графика. |
// + ----------------------------------------------- ------------------- +
color ChartBackColorGet (const long chart_ID = 0)
{
// --- подготовим переменную для получения цвета
длинный результат = clrNONE;
// --- сбросим значение ошибки
ResetLastError ();
// --- получим цвет фона графика
если (! ChartGetInteger (chart_ID, CHART_COLOR_BACKGROUND, 0, результат))
{
// --- выведено сообщение об ошибке в журнале "Эксперты"
Print (__ FUNCTION __ + ", Error Code =", GetLastError ());
}
// --- вернем значение свойства графика
вернуть ((цвет) результат);
}
// + ----------------------------------------------- ------------------- +
// | Функция доступна цвет фона графика. |
// + ----------------------------------------------- ------------------- +
bool ChartBackColorSet (const color clr, const long chart_ID = 0)
{
// --- сбросим значение ошибки
ResetLastError ();
// --- установим цвет фона графика
если (! ChartSetInteger (chart_ID, CHART_COLOR_BACKGROUND, CLR))
{
// --- выведено сообщение об ошибке в журнале "Эксперты"
Print (__ FUNCTION __ + ", Error Code =", GetLastError ());
возвращать (ложь);
}
// --- успешное выполнение
вернуться (истина);
}