Issue #290: MQL5 - added Timeframe into event MtTimeBarEvent

This commit is contained in:
Viacheslav Demydiuk
2026-04-06 21:53:50 +03:00
parent a8bb1a3af9
commit 9d178280d0
2 changed files with 5 additions and 2 deletions
BIN
View File
Binary file not shown.
+5 -2
View File
@@ -82,7 +82,7 @@ void OnTick()
MqlRates rates_array[];
CopyRates(symbol, Period(), 1, 1, rates_array);
MtTimeBarEvent time_bar(symbol, rates_array[0]);
MtTimeBarEvent time_bar(symbol, (int)Period(), rates_array[0]);
SendMtEvent(ON_LAST_TIME_BAR_EVENT, time_bar);
}
lastbar_time_changed = true;
@@ -3663,9 +3663,10 @@ private:
class MtTimeBarEvent: public MtObject
{
public:
MtTimeBarEvent(string symbol, const MqlRates& rates)
MtTimeBarEvent(string symbol, int timeframe, const MqlRates& rates)
{
_symbol = symbol;
_timeframe = timeframe;
_rates = rates;
}
@@ -3674,12 +3675,14 @@ public:
JSONObject *jo = new JSONObject();
jo.put("Rates", MqlRatesToJson(_rates));
jo.put("Instrument", new JSONString(_symbol));
jo.put("Timeframe", new JSONNumber(_timeframe));
jo.put("ExpertHandle", new JSONNumber(ExpertHandle));
return jo;
}
private:
string _symbol;
int _timeframe;
MqlRates _rates;
};