MT5-Chart v1.18: Trade-Marker, Liquiditaetszonen, Kurs oben rechts + Pfeil-Bugfix
Pfeil-Bugfix (User: "liquiditaetspfeile werden immer noch nicht angezeigt"):
(1) ANCHOR_LEFT ist fuer OBJ_ARROW UNGUELTIG (nur TOP/BOTTOM)
(2) Pfeile sitzen rechts neben der letzten Kerze -> ohne CHART_SHIFT kein
sichtbarer Bereich dort
Blink-Fix (User: "blinken nur manchmal auf"): hl_walls setzte den Cache bei jedem
Fehlschlag auf None -> LQ-Zeilen fehlten -> Indikator loeschte die Pfeile. Jetzt
letzter guter Stand 120s Grace.
Neu (alles reine Anzeige):
- TR;<O|C>;zeit -> Kerze der Eroeffnung HELLGRUEN, des Close DUNKELGRUEN umrandet
- EQ;<H|L>;lo;hi;zeit -> Equal Highs/Lows aus M30-Pivots als goldenes Band +
gestrichelte Kante (wie im User-Referenzbild). Als Signal gemessen verworfen.
- PX;bid -> aktueller Kurs fett oben rechts
- Beschriftung der Liquiditaets-Trendlinie per Default aus (v1.16)
Alles kompiliert und live in sr_levels.csv verifiziert.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b75997d703
commit
03567adf6b
+162
-13
@@ -12,7 +12,21 @@
|
||||
//| 4) Der Bot muss laufen (schreibt die CSV alle ~5 s). |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Oil Trading Bot"
|
||||
#property version "1.15"
|
||||
#property version "1.18"
|
||||
// v1.18 (2026-07-30): NEU (User-Wuensche) — (a) LIQUIDITAETSZONEN: Equal Highs /
|
||||
// Equal Lows aus den M30-Pivots als goldenes Band + gestrichelte Kante,
|
||||
// nach rechts verlaengert (EQ;<H|L>;lo;hi;zeit). REINE ANZEIGE, als Signal
|
||||
// gemessen verworfen. (b) AKTUELLER KURS oben rechts, fett (PX;bid).
|
||||
// v1.17 (2026-07-30): FIX „Liquiditaets-Pfeile werden nicht angezeigt" — zwei
|
||||
// Ursachen: (1) ANCHOR_LEFT ist fuer OBJ_ARROW UNGUELTIG (nur ANCHOR_TOP/
|
||||
// ANCHOR_BOTTOM), (2) die Pfeile sitzen rechts NEBEN der letzten Kerze —
|
||||
// ohne CHART_SHIFT gibt es dort keinen sichtbaren Bereich. Beides behoben.
|
||||
// NEU: TRADE-MARKER (TR;<O|C>;zeit) — die Kerze der Eroeffnung wird HELLGRUEN,
|
||||
// die des Close DUNKELGRUEN umrandet (InpShowTrades/InpTradeOpenColor/
|
||||
// InpTradeCloseColor).
|
||||
// v1.16 (2026-07-30): Beschriftung der Liquiditäts-Trendlinie per Default AUS
|
||||
// (User: „die beschreibung der liquiditätslinie kann ausgeblendet werden") —
|
||||
// Text steht jetzt im Tooltip der Linie; `InpLiqTrendLabel=true` holt sie zurück.
|
||||
// v1.15 (2026-07-30): CHART-THEME (User: „Farben im MT5 wie im Bild") — setzt beim
|
||||
// Start Hintergrund/Gitter/Kerzenfarben auf die Dashboard-Palette
|
||||
// (Bull #3B82F6, Bear #EF4444, BG #0D1117, Gitter #10151C dezent).
|
||||
@@ -56,6 +70,15 @@ input color InpWallBidColor = C'245,158,11'; // Liquidität Nachfrage (Bid)
|
||||
input color InpWallAskColor = C'245,158,11'; // Liquidität Angebot (Ask) — Gold
|
||||
input bool InpShowLiqTrend = true; // Liquiditäts-Trendlinie zeichnen
|
||||
input color InpLiqTrendColor = clrMagenta; // Liquiditäts-Trend (pink)
|
||||
input bool InpLiqTrendLabel = false; // Beschriftung der Trendlinie (aus per User-Wunsch)
|
||||
input bool InpShowTrades = true; // Trade-Kerzen umranden (Eroeffnung/Close)
|
||||
input color InpTradeOpenColor = C'134,239,172'; // Eroeffnung — hellgruen
|
||||
input color InpTradeCloseColor = C'21,128,61'; // Close — dunkelgruen
|
||||
input bool InpShowLiqZones = true; // Liquiditaetszonen (Equal Highs/Lows)
|
||||
input color InpLiqZoneColor = C'146,94,10'; // Zonen-Band (gedaempftes Gold)
|
||||
input bool InpShowPrice = true; // aktuellen Kurs oben rechts anzeigen
|
||||
input int InpPriceSize = 20; // Schriftgroesse des Kurses
|
||||
input color InpPriceColor = C'230,237,243'; // Kurs-Farbe
|
||||
// ── Chart-THEME (User-Vorgabe 2026-07-30 „Farben im MT5 wie im Bild") ────────
|
||||
// Setzt beim Start die Chart-Eigenschaften auf die Dashboard-Palette, damit MT5
|
||||
// und die PWA gleich aussehen. Farben in MQL5-Notation C'R,G,B'.
|
||||
@@ -107,6 +130,10 @@ void ApplyTheme()
|
||||
ChartSetInteger(0, CHART_COLOR_ASK, InpThemeBear);
|
||||
ChartSetInteger(0, CHART_COLOR_STOP_LEVEL, C'239,68,68');
|
||||
ChartSetInteger(0, CHART_SHOW_PERIOD_SEP, false);
|
||||
// ⚠ CHART_SHIFT MUSS an sein: die Liquiditäts-Pfeile sitzen rechts NEBEN der
|
||||
// letzten Kerze. Ohne Shift gibt es dort keinen sichtbaren Bereich → die Pfeile
|
||||
// wären unsichtbar (das war der zweite Grund für „Pfeile werden nicht angezeigt").
|
||||
ChartSetInteger(0, CHART_SHIFT, true);
|
||||
ChartRedraw();
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -354,7 +381,10 @@ void Redraw()
|
||||
ObjectSetInteger(0, an, OBJPROP_ARROWCODE, (dirc == "U" ? 233 : 234));
|
||||
ObjectSetInteger(0, an, OBJPROP_COLOR, lcol);
|
||||
ObjectSetInteger(0, an, OBJPROP_WIDTH, (isDom ? 4 : 2));
|
||||
ObjectSetInteger(0, an, OBJPROP_ANCHOR, ANCHOR_LEFT);
|
||||
// ⚠ KEIN ANCHOR_LEFT: OBJ_ARROW unterstützt NUR ANCHOR_TOP/ANCHOR_BOTTOM
|
||||
// — ein ungültiger Anker war (neben dem fehlenden Chart-Shift) der Grund,
|
||||
// warum die Pfeile nicht erschienen (Fix 2026-07-30).
|
||||
ObjectSetInteger(0, an, OBJPROP_ANCHOR, ANCHOR_TOP);
|
||||
ObjectSetInteger(0, an, OBJPROP_SELECTABLE, false);
|
||||
}
|
||||
else
|
||||
@@ -373,6 +403,116 @@ void Redraw()
|
||||
ObjectDelete(0, PFX + "TLQ_" + side);
|
||||
continue;
|
||||
}
|
||||
// LIQUIDITÄTSZONE: EQ;<H|L>;lo;hi;<broker_time> → goldenes Band über die
|
||||
// Equal Highs / Equal Lows (M30), ab dem ersten Pivot nach rechts verlängert,
|
||||
// plus gestrichelte Kante — Darstellung wie im Referenzbild des Users.
|
||||
// ⚠ REINE ANZEIGE: als Signal gemessen und verworfen (backtest_liquidity_sweep.py).
|
||||
if(typ == "EQ")
|
||||
{
|
||||
if(k < 5) continue;
|
||||
if(!InpShowLiqZones) continue;
|
||||
string zs = p[1];
|
||||
double zlo = StringToDouble(p[2]), zhi = StringToDouble(p[3]);
|
||||
datetime zt = (datetime)StringToInteger(p[4]);
|
||||
if(zlo <= 0 || zhi <= 0 || zt <= 0) continue;
|
||||
datetime zend = iTime(_Symbol, PERIOD_CURRENT, 0) + (datetime)(PeriodSeconds() * 3);
|
||||
string zn = PFX + "EQZ_" + zs;
|
||||
if(ObjectCreate(0, zn, OBJ_RECTANGLE, 0, zt, zlo, zend, zhi))
|
||||
{
|
||||
ObjectSetInteger(0, zn, OBJPROP_COLOR, InpLiqZoneColor);
|
||||
ObjectSetInteger(0, zn, OBJPROP_STYLE, STYLE_SOLID);
|
||||
ObjectSetInteger(0, zn, OBJPROP_WIDTH, 1);
|
||||
ObjectSetInteger(0, zn, OBJPROP_FILL, true);
|
||||
ObjectSetInteger(0, zn, OBJPROP_BACK, true);
|
||||
ObjectSetInteger(0, zn, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetString (0, zn, OBJPROP_TOOLTIP,
|
||||
(zs == "H" ? "Equal Highs - Sell-Side Liquidity"
|
||||
: "Equal Lows - Buy-Side Liquidity"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectMove(0, zn, 0, zt, zlo);
|
||||
ObjectMove(0, zn, 1, zend, zhi);
|
||||
}
|
||||
// gestrichelte Kante auf Höhe des Levels (wie im Bild)
|
||||
string zl = PFX + "EQL_" + zs;
|
||||
double edge = (zs == "H" ? zhi : zlo);
|
||||
if(ObjectCreate(0, zl, OBJ_TREND, 0, zt, edge, zend, edge))
|
||||
{
|
||||
ObjectSetInteger(0, zl, OBJPROP_COLOR, InpLiqZoneColor);
|
||||
ObjectSetInteger(0, zl, OBJPROP_STYLE, STYLE_DASH);
|
||||
ObjectSetInteger(0, zl, OBJPROP_WIDTH, 1);
|
||||
ObjectSetInteger(0, zl, OBJPROP_RAY_RIGHT, true);
|
||||
ObjectSetInteger(0, zl, OBJPROP_BACK, true);
|
||||
ObjectSetInteger(0, zl, OBJPROP_SELECTABLE, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectMove(0, zl, 0, zt, edge);
|
||||
ObjectMove(0, zl, 1, zend, edge);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// AKTUELLER KURS oben rechts, fett (User-Wunsch): PX;bid
|
||||
if(typ == "PX")
|
||||
{
|
||||
if(k < 2) continue;
|
||||
if(!InpShowPrice) continue;
|
||||
double pxv = StringToDouble(p[1]);
|
||||
if(pxv <= 0) continue;
|
||||
string pn = PFX + "PRICE";
|
||||
if(ObjectFind(0, pn) < 0)
|
||||
{
|
||||
ObjectCreate(0, pn, OBJ_LABEL, 0, 0, 0);
|
||||
ObjectSetInteger(0, pn, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
||||
ObjectSetInteger(0, pn, OBJPROP_XDISTANCE, 12);
|
||||
ObjectSetInteger(0, pn, OBJPROP_YDISTANCE, 14);
|
||||
ObjectSetInteger(0, pn, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
||||
ObjectSetString (0, pn, OBJPROP_FONT, "Arial Black");
|
||||
ObjectSetInteger(0, pn, OBJPROP_FONTSIZE, InpPriceSize);
|
||||
ObjectSetInteger(0, pn, OBJPROP_SELECTABLE, false);
|
||||
}
|
||||
ObjectSetString (0, pn, OBJPROP_TEXT, DoubleToString(pxv, (int)_Digits));
|
||||
ObjectSetInteger(0, pn, OBJPROP_COLOR, InpPriceColor);
|
||||
continue;
|
||||
}
|
||||
// TRADE-MARKER: TR;<O|C>;<broker_time> → die Kerze, in der eröffnet bzw.
|
||||
// geschlossen wurde, wird umrandet (User-Vorgabe 2026-07-30):
|
||||
// O = Eröffnung → HELLGRÜN · C = Close → DUNKELGRÜN
|
||||
// Umrandung = OBJ_RECTANGLE über die Bar-Spanne (Zeit) und High/Low (Preis),
|
||||
// ungefüllt. Die Zeit wird auf den Bar-Beginn der aktuellen Chart-TF gerundet,
|
||||
// damit die Box exakt auf einer Kerze sitzt — egal auf welcher TF man schaut.
|
||||
if(typ == "TR")
|
||||
{
|
||||
if(k < 3) continue;
|
||||
if(!InpShowTrades) continue;
|
||||
string tkind = p[1];
|
||||
datetime tts = (datetime)StringToInteger(p[2]);
|
||||
if(tts <= 0) continue;
|
||||
int bi = iBarShift(_Symbol, PERIOD_CURRENT, tts, false);
|
||||
if(bi < 0) continue; // Zeit liegt außerhalb der History
|
||||
datetime bt = iTime(_Symbol, PERIOD_CURRENT, bi);
|
||||
double bh = iHigh(_Symbol, PERIOD_CURRENT, bi);
|
||||
double bl = iLow (_Symbol, PERIOD_CURRENT, bi);
|
||||
if(bh <= 0 || bl <= 0) continue;
|
||||
double pad = (bh - bl) * 0.12; // etwas Luft um die Kerze
|
||||
if(pad <= 0) pad = _Point * 10;
|
||||
string tn2 = PFX + "TRD_" + tkind + "_" + IntegerToString((int)tts);
|
||||
if(ObjectCreate(0, tn2, OBJ_RECTANGLE, 0, bt, bl - pad,
|
||||
bt + PeriodSeconds(), bh + pad))
|
||||
{
|
||||
ObjectSetInteger(0, tn2, OBJPROP_COLOR,
|
||||
(tkind == "O" ? InpTradeOpenColor : InpTradeCloseColor));
|
||||
ObjectSetInteger(0, tn2, OBJPROP_STYLE, STYLE_SOLID);
|
||||
ObjectSetInteger(0, tn2, OBJPROP_WIDTH, 2);
|
||||
ObjectSetInteger(0, tn2, OBJPROP_FILL, false);
|
||||
ObjectSetInteger(0, tn2, OBJPROP_BACK, false);
|
||||
ObjectSetInteger(0, tn2, OBJPROP_SELECTABLE, false);
|
||||
ObjectSetString (0, tn2, OBJPROP_TOOLTIP,
|
||||
(tkind == "O" ? "Trade EROEFFNET" : "Trade GESCHLOSSEN"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Liquiditäts-TRENDLINIE: LT;t1;p1;t2;p2;<U|D> (pink, nach rechts verlängert).
|
||||
// Regression über den VOLUMENGEWICHTETEN Schwerpunkt der beiden Wände über die
|
||||
// letzten ~60 min: zeigt, wohin das Gewicht der RUHENDEN Orders wandert —
|
||||
@@ -404,21 +544,30 @@ void Redraw()
|
||||
ObjectMove(0, nm, 0, t1, q1);
|
||||
ObjectMove(0, nm, 1, t2, q2);
|
||||
}
|
||||
// Beschriftung der Liquiditäts-Trendlinie: auf User-Wunsch (2026-07-30)
|
||||
// per Default AUS — der Chart soll sauber bleiben. Die Richtung liest man
|
||||
// an der Linie selbst ab; Details stehen im Tooltip der Linie.
|
||||
string tl = PFX + "TLIQTREND";
|
||||
string tt = "Liquiditäts-Trend " + (td == "U" ? CharToString(94) : CharToString(118));
|
||||
if(ObjectCreate(0, tl, OBJ_TEXT, 0, t2, q2))
|
||||
string tt = "Liquiditaets-Trend " + (td == "U" ? CharToString(94) : CharToString(118));
|
||||
ObjectSetString(0, nm, OBJPROP_TOOLTIP, tt);
|
||||
if(InpLiqTrendLabel)
|
||||
{
|
||||
ObjectSetString (0, tl, OBJPROP_TEXT, tt);
|
||||
ObjectSetInteger(0, tl, OBJPROP_COLOR, InpLiqTrendColor);
|
||||
ObjectSetInteger(0, tl, OBJPROP_FONTSIZE, 9);
|
||||
ObjectSetInteger(0, tl, OBJPROP_ANCHOR, ANCHOR_LOWER);
|
||||
ObjectSetInteger(0, tl, OBJPROP_SELECTABLE, false);
|
||||
if(ObjectCreate(0, tl, OBJ_TEXT, 0, t2, q2))
|
||||
{
|
||||
ObjectSetString (0, tl, OBJPROP_TEXT, tt);
|
||||
ObjectSetInteger(0, tl, OBJPROP_COLOR, InpLiqTrendColor);
|
||||
ObjectSetInteger(0, tl, OBJPROP_FONTSIZE, 9);
|
||||
ObjectSetInteger(0, tl, OBJPROP_ANCHOR, ANCHOR_LOWER);
|
||||
ObjectSetInteger(0, tl, OBJPROP_SELECTABLE, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectMove(0, tl, 0, t2, q2);
|
||||
ObjectSetString(0, tl, OBJPROP_TEXT, tt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectMove(0, tl, 0, t2, q2);
|
||||
ObjectSetString(0, tl, OBJPROP_TEXT, tt);
|
||||
}
|
||||
ObjectDelete(0, tl); // evtl. Alt-Label aus v1.13–1.15 entfernen
|
||||
continue;
|
||||
}
|
||||
// ("Z;"-Zonen-Zeilen schreibt der Bot nicht mehr — die dynamische Handels-
|
||||
|
||||
Reference in New Issue
Block a user