mql5/Experts/Motivated/Graphics/VisualLevels.mqh

70 lines
2.6 KiB
MQL5

2026-06-10 18:31:08 +02:00
//+------------------------------------------------------------------+
//| VisualLevels.mqh |
//| Copyright 2025, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#include "VisualInterfaces.mqh"
#include "VisualSystem.mqh"
#include "Zonelevel.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class PointLevel : public ZoneLevel
{
private:
public:
2026-06-10 23:03:10 +02:00
PointLevel(string name, TimePrice &_point, string text = "", string extText = "", color clr = clrYellow, int width = 2)
: ZoneLevel(name, text, extText, 0, clr, width)
2026-06-10 18:31:08 +02:00
{
a.Set(_point);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2026-06-10 23:03:10 +02:00
virtual bool IsVisible(datetime fromTime, datetime toTime, double minPrice, double maxPrice)
2026-06-10 18:31:08 +02:00
{
2026-06-23 21:44:37 +02:00
ZoneLevel::IsVisible( fromTime, toTime, minPrice, maxPrice);
2026-06-10 18:31:08 +02:00
// Print("[PointLevel]::IsVisible() ",fromTime," :: ", a.x,"-- ", a.x >= fromTime);
2026-06-10 23:03:10 +02:00
return (a.x >= fromTime && a.x <= toTime && a.y >= minPrice && a.y <= maxPrice);
2026-06-10 18:31:08 +02:00
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
virtual void Draw(long chart_id, VisualSystem *vs)
{
2026-06-23 21:44:37 +02:00
2026-06-10 18:31:08 +02:00
if(CheckPointer(vs) == POINTER_INVALID)
return;
2026-06-10 23:03:10 +02:00
ObjectCreate(chart_id, levelObjName, OBJ_TEXT, 0, a.x, a.y);
2026-06-10 18:31:08 +02:00
ObjectSetString(chart_id, levelObjName, OBJPROP_TEXT, "●");
ObjectSetInteger(chart_id, levelObjName, OBJPROP_COLOR, levelColor);
ObjectSetInteger(0, levelObjName, OBJPROP_ANCHOR, ANCHOR_CENTER);
2026-06-10 23:03:10 +02:00
ObjectSetInteger(0, levelObjName, OBJPROP_FONTSIZE, 7);
2026-06-10 18:31:08 +02:00
if(levelText != "" && vs.Zoom() >= 2)
{
DrawText(levelTextObjName, levelText, a);
2026-06-23 21:44:37 +02:00
// SetFontSize(vs.GetScaledFontSize(12));
}
if(!isDrawExt)
{
DrawExt(chart_id, vs);
2026-06-10 18:31:08 +02:00
}
2026-06-10 23:03:10 +02:00
2026-06-10 18:31:08 +02:00
}
};
//+------------------------------------------------------------------+