2026-04-27 22:49:28 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Symbol.mqh |
|
| | | //| Copyright 2026, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/es/users/nique_372 |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2026, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/es/users/nique_372"
|
| | | #property strict
|
| | |
|
| | | #ifndef FULLMT5MCPBYLEO_SRC_DATA_SYMBOL_MQH
|
| | | #define FULLMT5MCPBYLEO_SRC_DATA_SYMBOL_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Include |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "..\\Def\\Def.mqh"
|
| | |
|
2026-06-03 20:39:25 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
2026-04-27 22:49:28 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| symbols_total |
|
| | | //+------------------------------------------------------------------+
|
| | | class CMcpFuncSymbolsTotal : public CMcpFunction
|
| | | {
|
| | | public:
|
| | | CMcpFuncSymbolsTotal() : CMcpFunction(0, false, "symbols_total") {}
|
| | | ~CMcpFuncSymbolsTotal(void) {}
|
| | |
|
2026-07-13 21:11:54 -05:00 | | | void Run(CJsonNode& param, CJsonBuilderStr* &out) override final;
|
2026-04-27 22:49:28 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-13 21:11:54 -05:00 | | | void CMcpFuncSymbolsTotal::Run(CJsonNode& param, CJsonBuilderStr* &out)
|
2026-04-27 22:49:28 -05:00 | | | {
|
2026-07-13 21:11:54 -05:00 | | | //---
|
| | | out = m_shared_builder;
|
2026-04-28 08:52:21 -05:00 | | | const int total = SymbolsTotal(param["only_selected_in_market_watch"].ToBool(false));
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(true);
|
| | | m_shared_builder.KeyWV("result").Val(total);
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-27 22:49:28 -05:00 | | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| symbol_select |
|
| | | //+------------------------------------------------------------------+
|
| | | class CMcpFuncSymbolSelect : public CMcpFunction
|
| | | {
|
| | | public:
|
| | | CMcpFuncSymbolSelect() : CMcpFunction(0, false, "symbol_select") {}
|
| | | ~CMcpFuncSymbolSelect(void) {}
|
| | |
|
2026-07-13 21:11:54 -05:00 | | | void Run(CJsonNode& param, CJsonBuilderStr* &out) override final;
|
2026-04-27 22:49:28 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-13 21:11:54 -05:00 | | | void CMcpFuncSymbolSelect::Run(CJsonNode& param, CJsonBuilderStr* &out)
|
2026-04-27 22:49:28 -05:00 | | | {
|
2026-07-13 21:11:54 -05:00 | | | //---
|
| | | out = m_shared_builder;
|
2026-04-27 22:49:28 -05:00 | | | ::ResetLastError();
|
2026-04-28 08:52:21 -05:00 | | | const bool result = SymbolSelect(param["symbol"].ToString(_Symbol), param["select"].ToBool(true) != 0);
|
2026-04-27 22:49:28 -05:00 | | |
|
| | | //---
|
| | | if(!result)
|
| | | {
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("symbol_select failed, last mt5 error = %d", ::GetLastError()));
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-27 22:49:28 -05:00 | | | return;
|
| | | }
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(true);
|
| | | m_shared_builder.KeyWV("result").Val(true);
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-27 22:49:28 -05:00 | | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| symbol_info_double |
|
| | | //+------------------------------------------------------------------+
|
2026-04-29 07:59:28 -05:00 | | | class CMcpFuncSymbolInfo : public CMcpFunction
|
2026-04-27 22:49:28 -05:00 | | | {
|
| | | public:
|
2026-04-29 07:59:28 -05:00 | | | CMcpFuncSymbolInfo() : CMcpFunction(0, false, "symbol_info") {}
|
| | | ~CMcpFuncSymbolInfo(void) {}
|
2026-04-27 22:49:28 -05:00 | | |
|
2026-07-13 21:11:54 -05:00 | | | void Run(CJsonNode& param, CJsonBuilderStr* &out) override final;
|
2026-04-27 22:49:28 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-13 21:11:54 -05:00 | | | void CMcpFuncSymbolInfo::Run(CJsonNode& param, CJsonBuilderStr* &out)
|
2026-04-27 22:49:28 -05:00 | | | {
|
2026-04-28 08:52:21 -05:00 | | | //---
|
2026-07-13 21:11:54 -05:00 | | | out = m_shared_builder;
|
2026-04-27 22:49:28 -05:00 | | | const string symbol = param["symbol"].ToString(_Symbol);
|
2026-06-03 20:39:25 -05:00 | | | const int8_t mode = (int8_t)param["mode"].ToInt(0);
|
2026-04-29 07:59:28 -05:00 | | |
|
2026-04-27 22:49:28 -05:00 | | | //---
|
2026-04-29 07:59:28 -05:00 | | | switch(mode)
|
| | | {
|
| | | case 0: // DBL
|
| | | {
|
| | | double value;
|
| | | //---
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | if(SymbolInfoDouble(symbol, CEnumRegBasis::GetValNoRef<ENUM_SYMBOL_INFO_DOUBLE>(param["property"].ToString(""), WRONG_VALUE), value))
|
| | | {
|
| | | m_shared_builder.KeyWV("ok").Val(true);
|
| | | m_shared_builder.KeyWV("result").Val(value);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Error call SymbolInfoDouble, mt5 last err = %d", ::GetLastError()));
|
| | | }
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | break;
|
| | | }
|
| | |
|
| | | case 1: // INTEGER
|
| | | {
|
| | | long value;
|
| | | //---
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | if(SymbolInfoInteger(symbol, CEnumRegBasis::GetValNoRef<ENUM_SYMBOL_INFO_INTEGER>(param["property"].ToString(""), WRONG_VALUE), value))
|
| | | {
|
| | | m_shared_builder.KeyWV("ok").Val(true);
|
| | | m_shared_builder.KeyWV("result").Val(value);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Eror call symbolinfointeger, mt5 last err = %d", ::GetLastError()));
|
| | | }
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | break;
|
| | | }
|
| | | case 2: // STRING
|
| | | {
|
| | | string value;
|
| | | //---
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | if(SymbolInfoString(symbol, CEnumRegBasis::GetValNoRef<ENUM_SYMBOL_INFO_STRING>(param["property"].ToString(""), WRONG_VALUE), value))
|
| | | {
|
| | | m_shared_builder.KeyWV("ok").Val(true);
|
| | | m_shared_builder.KeyWV("result").ValS(value);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Error call SymbolInfoString, mt5 last err = %d", ::GetLastError()));
|
| | | }
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | break;
|
| | | }
|
| | | default:
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Invalid mode = %d", mode));
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | break;
|
| | | }
|
2026-04-27 22:49:28 -05:00 | | | }
|
2026-04-29 07:59:28 -05:00 | | |
|
2026-04-27 22:49:28 -05:00 | | | //+------------------------------------------------------------------+
|
2026-04-29 07:59:28 -05:00 | | | //| |
|
2026-04-27 22:49:28 -05:00 | | | //+------------------------------------------------------------------+
|
2026-04-29 07:59:28 -05:00 | | | class CMcpFuncSymbolInfoSession : public CMcpFunction
|
2026-04-27 22:49:28 -05:00 | | | {
|
| | | public:
|
2026-04-29 07:59:28 -05:00 | | | CMcpFuncSymbolInfoSession(void) : CMcpFunction(0, false, "symbol_info_session") {}
|
| | | ~CMcpFuncSymbolInfoSession(void) {}
|
2026-07-13 21:11:54 -05:00 | | | void Run(CJsonNode& param, CJsonBuilderStr* &out) override final;
|
2026-04-27 22:49:28 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-13 21:11:54 -05:00 | | | void CMcpFuncSymbolInfoSession::Run(CJsonNode ¶m, CJsonBuilderStr* &out)
|
2026-04-27 22:49:28 -05:00 | | | {
|
2026-07-13 21:11:54 -05:00 | | | //---
|
| | | out = m_shared_builder;
|
2026-04-29 07:59:28 -05:00 | | | ::ResetLastError();
|
2026-06-03 20:39:25 -05:00 | | | const int8_t mode = (int8_t)param["mode"].ToInt(0);
|
2026-04-29 07:59:28 -05:00 | | | datetime to, from;
|
| | | switch(mode)
|
| | | {
|
| | | case 0:
|
| | | {
|
2026-06-28 22:09:10 -05:00 | | | if(!SymbolInfoSessionTrade(param["symbol"].ToString(), CEnumRegBasis::GetValNoRef<ENUM_DAY_OF_WEEK>(param["day_of_week"].ToString(""), WRONG_VALUE), uint(param["session_index"].ToInt(0)), from, to))
|
2026-04-29 07:59:28 -05:00 | | | {
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Error call SymbolInfoSessionTrade, mt5 last err = %d", ::GetLastError()));
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | return;
|
| | | }
|
| | | break;
|
| | | }
|
| | |
|
| | | case 1:
|
| | | {
|
2026-06-28 22:09:10 -05:00 | | | if(!SymbolInfoSessionQuote(param["symbol"].ToString(), CEnumRegBasis::GetValNoRef<ENUM_DAY_OF_WEEK>(param["day_of_week"].ToString(""), WRONG_VALUE), uint(param["session_index"].ToInt(0)), from, to))
|
2026-04-29 07:59:28 -05:00 | | | {
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Error call SymbolInfoSessionQuote, mt5 last err = %d", ::GetLastError()));
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | return;
|
| | | }
|
| | | break;
|
| | | }
|
| | | default:
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(false);
|
| | | m_shared_builder.KeyWV("error").ValSWV(StringFormat("Invalid mode = %d", mode));
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-29 07:59:28 -05:00 | | | return;
|
| | | }
|
2026-07-13 21:11:54 -05:00 | | | m_shared_builder.PutChar('"');
|
| | | m_shared_builder.Obj();
|
| | | m_shared_builder.KeyWV("ok").Val(true);
|
| | | m_shared_builder.KeyWV("result").Obj();
|
| | | m_shared_builder.KeyWV("date_from").ValSWV(TimeToString(from, TIME_DATE | TIME_MINUTES | TIME_SECONDS));
|
| | | m_shared_builder.KeyWV("date_to").ValSWV(TimeToString(to, TIME_DATE | TIME_MINUTES | TIME_SECONDS));
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.EndObj();
|
| | | m_shared_builder.PutChar('"');
|
2026-04-27 22:49:28 -05:00 | | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-06-03 20:39:25 -05:00 | | | } // namespace TSN
|
2026-04-27 22:49:28 -05:00 | | | #endif // FULLMT5MCPBYLEO_SRC_DATA_SYMBOL_MQH
|