Initial commit: Mad Turtle v2.0 ML EA for XAUUSD H1 with Python inference server and MQL5 EA
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| MadTurtle_UI.mqh - Status Dashboard, P&L, Signal Oscillator |
|
||||
//+------------------------------------------------------------------+
|
||||
#ifndef MADTURTLE_UI
|
||||
#define MADTURTLE_UI
|
||||
|
||||
// UI color theme
|
||||
#define UI_COLOR_BG clrBlack
|
||||
#define UI_COLOR_PANEL clrDarkSlateGray
|
||||
#define UI_COLOR_TEXT clrWhite
|
||||
#define UI_COLOR_PROFIT clrLime
|
||||
#define UI_COLOR_LOSS clrRed
|
||||
#define UI_COLOR_BUY clrDodgerBlue
|
||||
#define UI_COLOR_SELL clrOrangeRed
|
||||
#define UI_COLOR_HOLD clrGray
|
||||
#define UI_COLOR_ACCENT clrAqua
|
||||
|
||||
// Panel layout (x, y, w, h)
|
||||
#define UI_STATUS_X 10
|
||||
#define UI_STATUS_Y 10
|
||||
#define UI_STATUS_W 280
|
||||
#define UI_STATUS_H 180
|
||||
|
||||
#define UI_METRICS_X 10
|
||||
#define UI_METRICS_Y 200
|
||||
#define UI_METRICS_W 280
|
||||
#define UI_METRICS_H 120
|
||||
|
||||
#define UI_OSC_X 300
|
||||
#define UI_OSC_Y 10
|
||||
#define UI_OSC_W 220
|
||||
#define UI_OSC_H 140
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Draw rounded rectangle panel |
|
||||
//+------------------------------------------------------------------+
|
||||
void MadTurtle_DrawPanel(int x, int y, int w, int h, color bg = UI_COLOR_PANEL, color border = UI_COLOR_ACCENT)
|
||||
{
|
||||
string name = StringFormat("panel_bg_%d_%d", x, y);
|
||||
if(ObjectFind(0, name) < 0) {
|
||||
ObjectCreate(0, name, OBJ_RECTANGLE, 0, 0, 0);
|
||||
}
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, w);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, h);
|
||||
ObjectSetInteger(0, name, OBJPROP_COLOR, border);
|
||||
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_SOLID);
|
||||
ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
|
||||
ObjectSetInteger(0, name, OBJPROP_FILL, true);
|
||||
ObjectSetInteger(0, name, OBJPROP_BGCOLOR, bg);
|
||||
ObjectSetInteger(0, name, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Draw label text on panel |
|
||||
//+------------------------------------------------------------------+
|
||||
void MadTurtle_DrawLabel(string objName, string text, int x, int y, int fontSize = 9,
|
||||
color clr = UI_COLOR_TEXT, int anchor = ANCHOR_LEFT_UPPER)
|
||||
{
|
||||
if(ObjectFind(0, objName) < 0) {
|
||||
ObjectCreate(0, objName, OBJ_LABEL, 0, 0, 0);
|
||||
}
|
||||
ObjectSetInteger(0, objName, OBJPROP_XDISTANCE, x);
|
||||
ObjectSetInteger(0, objName, OBJPROP_YDISTANCE, y);
|
||||
ObjectSetString(0, objName, OBJPROP_TEXT, text);
|
||||
ObjectSetInteger(0, objName, OBJPROP_COLOR, clr);
|
||||
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, fontSize);
|
||||
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, anchor);
|
||||
ObjectSetInteger(0, objName, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetInteger(0, objName, OBJPROP_HIDDEN, true);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Draw mini equity curve (simple text + bar) |
|
||||
//+------------------------------------------------------------------+
|
||||
void MadTurtle_DrawEquityCurve(double &equity[], int x, int y, int w, int h, color lineClr = UI_COLOR_PROFIT)
|
||||
{
|
||||
int n = ArraySize(equity);
|
||||
if(n < 2) return;
|
||||
|
||||
double minE = equity[ArrayMinimum(equity)];
|
||||
double maxE = equity[ArrayMaximum(equity)];
|
||||
if(maxE - minE < 1e-6) maxE = minE + 1.0;
|
||||
|
||||
// Draw as vertical bars in a rectangle
|
||||
int barW = (int)((double)w / n);
|
||||
if(barW < 1) barW = 1;
|
||||
|
||||
for(int i = 0; i < n; i++) {
|
||||
int barH = (int)((equity[i] - minE) / (maxE - minE) * h);
|
||||
if(barH < 1) barH = 1;
|
||||
string barName = StringFormat("eq_bar_%d", i);
|
||||
if(ObjectFind(0, barName) < 0) {
|
||||
ObjectCreate(0, barName, OBJ_RECTANGLE, 0, 0, 0);
|
||||
}
|
||||
ObjectSetInteger(0, barName, OBJPROP_XDISTANCE, x + i * barW);
|
||||
ObjectSetInteger(0, barName, OBJPROP_YDISTANCE, y + h - barH);
|
||||
ObjectSetInteger(0, barName, OBJPROP_XSIZE, barW);
|
||||
ObjectSetInteger(0, barName, OBJPROP_YSIZE, barH);
|
||||
ObjectSetInteger(0, barName, OBJPROP_COLOR, lineClr);
|
||||
ObjectSetInteger(0, barName, OBJPROP_FILL, true);
|
||||
ObjectSetInteger(0, barName, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetInteger(0, barName, OBJPROP_HIDDEN, true);
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Draw signal oscillator bars (buy/sell confidence) |
|
||||
//+------------------------------------------------------------------+
|
||||
void MadTurtle_DrawOscillator(double buyConf, double sellConf, int x, int y, int w, int h)
|
||||
{
|
||||
string objBuy = "osc_buy_bar";
|
||||
string objSell = "osc_sell_bar";
|
||||
|
||||
if(ObjectFind(0, objBuy) < 0) ObjectCreate(0, objBuy, OBJ_RECTANGLE, 0, 0, 0);
|
||||
if(ObjectFind(0, objSell) < 0) ObjectCreate(0, objSell, OBJ_RECTANGLE, 0, 0, 0);
|
||||
|
||||
int buyH = (int)(buyConf / 100.0 * h);
|
||||
int sellH = (int)(sellConf / 100.0 * h);
|
||||
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_XDISTANCE, x);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_YDISTANCE, y + h - buyH);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_XSIZE, w / 2 - 2);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_YSIZE, buyH);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_COLOR, UI_COLOR_BUY);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_FILL, true);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetInteger(0, objBuy, OBJPROP_HIDDEN, true);
|
||||
|
||||
ObjectSetInteger(0, objSell, OBJPROP_XDISTANCE, x + w / 2 + 2);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_YDISTANCE, y + h - sellH);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_XSIZE, w / 2 - 2);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_YSIZE, sellH);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_COLOR, UI_COLOR_SELL);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_FILL, true);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetInteger(0, objSell, OBJPROP_HIDDEN, true);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Clean up all UI objects on deinit |
|
||||
//+------------------------------------------------------------------+
|
||||
void MadTurtle_CleanupUI()
|
||||
{
|
||||
ObjectsDeleteAll(0, "panel_bg_");
|
||||
ObjectsDeleteAll(0, "ui_label_");
|
||||
ObjectsDeleteAll(0, "eq_bar_");
|
||||
ObjectsDeleteAll(0, "osc_");
|
||||
ObjectsDeleteAll(0, "sig_arrow_");
|
||||
}
|
||||
|
||||
#endif // MADTURTLE_UI
|
||||
Reference in New Issue
Block a user