支持中心 帮助文档 联系我们
📱 微信: 18391752892 | 💬 QQ: 3313198376 | ✈️ Telegram | 📧 fishfx123@gmail.com
EURUSD 1.0856 +0.12% GBPUSD 1.2678 +0.08% USDJPY 149.23 -0.15% XAUUSD 2034.56 +0.34% EURUSD 1.0856 +0.12% GBPUSD 1.2678 +0.08% USDJPY 149.23 -0.15% XAUUSD 2034.56 +0.34%

Natural Language Processing NLP

👤 作者: Abhijay Tiwari

4.5 分

¥0.00

📌 版本: v1.3
📥 下载: 0
⭐ 评分: 4.5

📝 产品详情

Natural Language Processing NLP

作者Abhijay Tiwari
版本v1.3
激活数0

? Overview

AlgoNLP.mqh is a standalone MQL5 library that converts human-written trading instructions into structured trade intents that your Expert Advisor (EA) or indicator can understand.

Example input:

Output intent:

This enables you to build chat-controlled or Telegram-integrated EAs that can interpret plain English commands and execute structured trades.

➡️ Check my Articles for deatiled explaintion on how NLP works and implement it using mq5.

⚙️ System Requirements

Requirement Details
Platform MetaTrader 5 (Build ≥ 2750)
Language MQL5 (strict mode enabled)
Encoding Unicode-Safe
Dependencies None (self-contained)
Execution Time ≈ 0.2 ms for an average sentence (<30 tokens)
Memory Footprint ≈ 20–30 KB per instance
Thread Safety Single-threaded (EA/indicator safe)

➡️ benchmarks may vary in real environments.

? Library Structure

Component Type Description
CNLP Main Manager Class Handles parsing, context binding, and listener dispatch.
CIntentDetector Core Engine Performs multi-pass number extraction and intent mapping.
CKeywordExtractor Utility Extracts keywords and filters stopwords.
CLexicon Utility Stores semantic word sets (buy/sell, order types).
CContext Helper Manages known symbols and last used instrument.
INLPListener Interface Callback interface for event-driven intent handling.
NLPUtil Namespace Text and timing utility functions.

➡️ View in-depth architecture diagram:


? Core Data Types

SNLPIntent — Parsed Trade Object

Field Type Description
valid bool True if parsed successfully
side ENLPOrderSide BUY, SELL, or UNKNOWN
type ENLPOrderType MARKET, LIMIT, STOP
symbol string Resolved trading symbol
price double Entry price (if provided)
tp, sl double Take-profit and stop-loss values
tp_is_percent, sl_is_percent bool True if % based
tp_is_pips, sl_is_pips bool True if in pips/points
qty_lots double Detected lot size
when SNLPWhen Time or breakout conditions
raw string Original message text
reason string Debugging or explanation field

? How It Works

  1. Normalization: Text is lowercased, cleaned, and synonyms replaced (take profit → tp).
  2. Tokenization: Words are split and stopwords filtered out.
  3. Lexical Matching: Detects intent direction using fuzzy Levenshtein distance ≤1.
  4. Number Context Extraction: Interprets numbers as price, TP/SL, or lot size via unit analysis.
  5. Timing Logic: Recognizes “at 09:15”, “in 15 min”, and breakout triggers.
  6. Symbol Resolution: Infers instruments like gold → XAUUSD.
  7. Intent Build: Constructs SNLPIntent and triggers listener callbacks.

? Example Integration

#include <AlgoNLP.mqh>

class CMyListener : public INLPListener
{
 public:
  void OnOrderIntent(const SNLPIntent &i) override
  {
     Print("✅ NLP Worked!");
     Print("Side: ", EnumToString(i.side));
     Print("Type: ", EnumToString(i.type));
     Print("Symbol: ", i.symbol);
     Print("TP: ", DoubleToString(i.tp, 2), " | SL: ", DoubleToString(i.sl, 2));
  }
};

CMyListener listener;
CNLP nlp;

int OnInit()
{
   nlp.AddSymbol("XAUUSDm");
   nlp.AddListener(listener);
   return(INIT_SUCCEEDED);
}

void OnStart()
{
   string text="Buy gold at 2370 with TP 0.3% and SL 1%";
   nlp.Dispatch(text);
}

? Performance Metrics

Test Case Tokens Parse Time Accuracy
Short Command (“Buy BTC market”) 5 0.09 ms 100%
Full Sentence (“Buy gold at 2370 with TP 0.3% and SL 1%”) 15 0.22 ms 100%
Noisy Query (“Hey bot short nasdaq please 0.5 lot”) 18 0.26 ms >95%

➡️ Benchmark performed on Intel i7-9700 / MT5 Build 3820.

? Summary

AlgoNLP.mqh transforms ordinary text into actionable trade logic inside MetaTrader. It’s designed for developers who want their EAs to think like humans — understanding plain English instructions and executing trades intelligently. This isn’t a shortcut — it’s a full linguistic computation system written in native MQL5.

安全须知

本产品仅通过 MQL5.com 官方渠道获取。其他渠道版本可能缺少完整功能和技术支持。

EA 配置

交易品种XAUUSD
时间框架H1 (推荐)
推荐经纪商IC Markets, IC Trading
最低存款$300 / 0.01手

📸 截图预览