75 lines
2.8 KiB
MQL5
75 lines
2.8 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Dashboard.mqh – zobrazení na grafu (Comment) |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "TestRefactor"
|
|
#property strict
|
|
|
|
#ifndef __DASHBOARD_MQH__
|
|
#define __DASHBOARD_MQH__
|
|
|
|
#include "Context.mqh"
|
|
#include "Positions.mqh"
|
|
#include "SignalEngine.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| CDashboard – sestaví a zobrazí text na grafu |
|
|
//+------------------------------------------------------------------+
|
|
class CDashboard {
|
|
private:
|
|
SContext m_ctx;
|
|
CPositions *m_positions;
|
|
CSignalEngine *m_signals;
|
|
string m_symbol;
|
|
|
|
public:
|
|
CDashboard() : m_positions(NULL), m_signals(NULL), m_symbol("") {}
|
|
|
|
void SetContext(const SContext &ctx) { m_ctx = ctx; }
|
|
void SetPositions(CPositions *pos) { m_positions = pos; }
|
|
void SetSignalEngine(CSignalEngine *sig) { m_signals = sig; }
|
|
void SetSymbol(string symbol) { m_symbol = symbol; }
|
|
|
|
void Update() {
|
|
if(!m_signals) { Comment(""); return; }
|
|
SLastBarValues bar = m_signals.GetLastBarValues();
|
|
double smaDistancePoints = MathAbs(bar.fastMa0 - bar.slowMa0) / _Point;
|
|
bool trendUp = true;
|
|
string trendStr = "off";
|
|
if(m_ctx.h1TrendMaPeriod > 0) {
|
|
SH1TrendResult h1 = m_signals.GetH1Trend();
|
|
if(h1.ok) { trendUp = h1.trendUp; trendStr = trendUp ? "UP" : "DOWN"; }
|
|
}
|
|
string tf1Str = "-", tf2Str = "-";
|
|
if(m_ctx.timeframe1MaPeriod > 0) {
|
|
SH1TrendResult tf1 = m_signals.GetTf1Trend();
|
|
if(tf1.ok) tf1Str = tf1.trendUp ? "UP" : "DOWN";
|
|
}
|
|
if(m_ctx.timeframe2MaPeriod > 0) {
|
|
SH1TrendResult tf2 = m_signals.GetTf2Trend();
|
|
if(tf2.ok) tf2Str = tf2.trendUp ? "UP" : "DOWN";
|
|
}
|
|
string gridStr = "off";
|
|
int nBuy = 0, nSell = 0;
|
|
if(m_positions) {
|
|
m_positions.Refresh();
|
|
nBuy = m_positions.CountBuy();
|
|
nSell = m_positions.CountSell();
|
|
if(m_ctx.tradeMode == TRADE_GRID)
|
|
gridStr = StringFormat("GRID dist=%g pt | Buy=%d | Sell=%d", m_ctx.gridDistancePoints, nBuy, nSell);
|
|
}
|
|
Comment(
|
|
"\nslowMa[0]: ", DoubleToString(bar.slowMa0, _Digits),
|
|
"\nslowMa[1]: ", DoubleToString(bar.slowMa1, _Digits),
|
|
"\nfastMa[0]: ", DoubleToString(bar.fastMa0, _Digits),
|
|
"\nfastMa[1]: ", DoubleToString(bar.fastMa1, _Digits),
|
|
"\nRSI: ", DoubleToString(bar.rsi0, 2),
|
|
"\nSMA distance (pt): ", DoubleToString(smaDistancePoints, 1),
|
|
"\nH1 trend (", m_ctx.h1TrendMaPeriod, "): ", trendStr,
|
|
"\nTF1 (", m_ctx.timeframe1MaPeriod, "): ", tf1Str,
|
|
"\nTF2 (", m_ctx.timeframe2MaPeriod, "): ", tf2Str,
|
|
"\n", gridStr
|
|
);
|
|
}
|
|
};
|
|
|
|
#endif
|