mql5/Experts/Motivated/Graphics/VisualLevels.mqh
younglubah-gmail 9639b8b362
2026-06-23 21:44:37 +02:00

70 lines
2.6 KiB
MQL5

//+------------------------------------------------------------------+
//| 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:
PointLevel(string name, TimePrice &_point, string text = "", string extText = "", color clr = clrYellow, int width = 2)
: ZoneLevel(name, text, extText, 0, clr, width)
{
a.Set(_point);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
virtual bool IsVisible(datetime fromTime, datetime toTime, double minPrice, double maxPrice)
{
ZoneLevel::IsVisible( fromTime, toTime, minPrice, maxPrice);
// Print("[PointLevel]::IsVisible() ",fromTime," :: ", a.x,"-- ", a.x >= fromTime);
return (a.x >= fromTime && a.x <= toTime && a.y >= minPrice && a.y <= maxPrice);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
virtual void Draw(long chart_id, VisualSystem *vs)
{
if(CheckPointer(vs) == POINTER_INVALID)
return;
ObjectCreate(chart_id, levelObjName, OBJ_TEXT, 0, a.x, a.y);
ObjectSetString(chart_id, levelObjName, OBJPROP_TEXT, "●");
ObjectSetInteger(chart_id, levelObjName, OBJPROP_COLOR, levelColor);
ObjectSetInteger(0, levelObjName, OBJPROP_ANCHOR, ANCHOR_CENTER);
ObjectSetInteger(0, levelObjName, OBJPROP_FONTSIZE, 7);
if(levelText != "" && vs.Zoom() >= 2)
{
DrawText(levelTextObjName, levelText, a);
// SetFontSize(vs.GetScaledFontSize(12));
}
if(!isDrawExt)
{
DrawExt(chart_id, vs);
}
}
};
//+------------------------------------------------------------------+