//+------------------------------------------------------------------+
//| Kin_Dza_Dza.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link "https://www.mql5.com/ru/users/s22aa"
#property version "1.00"
#include <Trade\PositionInfo.mqh>
CPositionInfo m_position;
input color chart_common = clrSilver;
input color chart_profit = clrLightGreen;
input color chart_loss = clrSalmon;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
long chart_id = ChartFirst();
for(int j = 0; j < CHARTS_MAX; j++)
{
if(ChartGetInteger(chart_id, CHART_COLOR_BACKGROUND) != chart_common)
ChartSetInteger(chart_id, CHART_COLOR_BACKGROUND, chart_common);
chart_id = ChartNext(chart_id);
if(chart_id < 0)
break;
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
long chart_id = ChartFirst();
for(int j = 0; j < CHARTS_MAX; j++)
{
if(m_position.Select(ChartSymbol(chart_id)))
{
if(m_position.Profit() + m_position.Commission() + m_position.Swap() > 0)
{
if(ChartGetInteger(chart_id, CHART_COLOR_BACKGROUND) != chart_profit)
ChartSetInteger(chart_id, CHART_COLOR_BACKGROUND, chart_profit);
}
else
if(ChartGetInteger(chart_id, CHART_COLOR_BACKGROUND) != chart_loss)
ChartSetInteger(chart_id, CHART_COLOR_BACKGROUND, chart_loss);
}
else
{
if(ChartGetInteger(chart_id, CHART_COLOR_BACKGROUND) != chart_common)
ChartSetInteger(chart_id, CHART_COLOR_BACKGROUND, chart_common);
}
chart_id = ChartNext(chart_id);
if(chart_id < 0)
break;
}
}
//+------------------------------------------------------------------+
Comments