2026-10-21 22:39:41 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Utils.mqh |
|
| | | //| Copyright 2026, Niquel Mendoza. |
|
| | | //| https://www.mql5.com |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2026, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com"
|
| | | #property strict
|
| | |
|
| | | #ifndef MQLARTICLES_UTILS_OBJECTS_UTILS_MQH
|
| | | #define MQLARTICLES_UTILS_OBJECTS_UTILS_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "Native\\Imp.mqh"
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class CObjGUtils
|
| | | {
|
| | | public:
|
| | | CObjGUtils(void) {}
|
| | | ~CObjGUtils(void) {}
|
| | |
|
| | | //---
|
| | | static void ModifiedIntegerPropertyByPrefix(long chart_id, int subwin, const string& prefix, ENUM_OBJECT obj_type, ENUM_OBJECT_PROPERTY_INTEGER property, long value);
|
| | |
|
| | | //---
|
| | | static void DrawTPSL(long chart_id, int subwin, const string& prefix_, double tp, double sl, double entry, datetime time_entry, datetime end_time
|
| | | , color clr_tp_, color clr_sl_, bool fill_rect, int width_rect_, ENUM_LINE_STYLE style_rect);
|
2026-10-22 21:57:02 -05:00 | | |
|
| | | //---
|
| | | static long BarrasInRange(datetime init_time, datetime end_time, ENUM_TIMEFRAMES timeframe);
|
2026-10-21 22:39:41 -05:00 | | | };
|
| | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | static void CObjGUtils::ModifiedIntegerPropertyByPrefix(long chart_id, int subwin, const string& prefix, ENUM_OBJECT obj_type, ENUM_OBJECT_PROPERTY_INTEGER property, long value)
|
| | | {
|
| | | //---
|
| | | int objtotal = ObjectsTotal(chart_id, subwin, obj_type);
|
| | |
|
| | | //---
|
| | | for(int i = 0; i < objtotal ; i++)
|
| | | {
|
| | | const string obj_name = ObjectName(chart_id, i, subwin, obj_type);
|
| | | if(StringFind(obj_name, prefix, 0) >= 0)
|
| | | {
|
| | | ObjectSetInteger(chart_id, obj_name, property, value);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | static void CObjGUtils::DrawTPSL(long chart_id, int subwin, const string& prefix_, double tp, double sl, double entry, datetime time_entry, datetime end_time
|
| | | , color clr_tp_, color clr_sl_, bool fill_rect, int width_rect_, ENUM_LINE_STYLE style_rect)
|
| | | {
|
| | | //---
|
| | | const string name_rect_tp = prefix_ + "tp_" + TimeToString(end_time);
|
| | | const string name_rect_sl = prefix_ + "sl_" + TimeToString(end_time);
|
| | |
|
| | | //---
|
| | | TSN::CNativeoGObjs::RectangleCreate(chart_id, name_rect_tp, subwin, time_entry, entry, end_time, tp, clr_tp_, width_rect_, fill_rect, true, false, style_rect, "Take profit");
|
| | | TSN::CNativeoGObjs::RectangleCreate(chart_id, name_rect_sl, subwin, time_entry, entry, end_time, sl, clr_sl_, width_rect_, fill_rect, true, false, style_rect, "Stop Loss");
|
| | | }
|
2026-10-22 21:57:02 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | static long CObjGUtils::BarrasInRange(datetime init_time, datetime end_time, ENUM_TIMEFRAMES timeframe)
|
| | | {
|
| | | return (init_time > end_time) ? 0 : iBarShift(_Symbol, timeframe, init_time) - iBarShift(_Symbol, timeframe, end_time);
|
| | | }
|
2026-10-21 22:39:41 -05:00 | | | //+------------------------------------------------------------------+
|
| | | }
|
| | | #endif // MQLARTICLES_UTILS_OBJECTS_UTILS_MQH
|
| | | //+------------------------------------------------------------------+
|