Teddy — Backend & packaging

Uncompiled MQL5 example shown as inert text, not deployed/executed. Idempotency and partial-failure cleanup are not established by this sample. No trading authority is granted.

ที่มา: 06_teddy_mql5_execution_engine.mqh
Source SHA-256: 023bea34529dbb8f6217ddd6a607afdab7aee1dbc9172013566cb5d5dfed9347

Published excerpt/source viewer; original archived privately. Hash identifies source bytes, not authorship, endorsement or production acceptance.

//+------------------------------------------------------------------+
//|                                       GHR_Execution_Engine.mqh   |
//|               Copyright 2026, NakharaX Group Quantitative Team   |
//|                                  Author: Teddy (Backend Lead)    |
//+------------------------------------------------------------------+
#property copyright "NakharaX Group"
#property link      "https://nakharax.com"
#property version   "3.10"
#property strict

#include <Trade\Trade.mqh>

enum ENUM_GHR_STATE {
   STATE_0_FULL_SL    = 0, // All legs hit SL (-1.00R)
   STATE_1_TP1_HIT    = 1, // TP1 banked +300 pts (-0.675R)
   STATE_2_TP2_HIT    = 2, // TP1-2 banked +900 pts (-0.275R)
   STATE_3_TP3_HIT    = 3, // TP1-3 banked +1800 pts (+0.200R)
   STATE_4_ALL_TP_HIT = 4  // All 4 TPs completed (+0.750R)
};

class CGHRExecutionEngine {
private:
   CTrade         m_trade;
   ulong          m_magic_base;
   double         m_stop_loss_pts;
   double         m_tp_steps[4];
   
public:
   CGHRExecutionEngine(ulong magic = 994001) {
      m_magic_base = magic;
      m_stop_loss_pts = 1000.0; // Strictly 1,000 Points
      m_tp_steps[0] = 300.0;   // TP1
      m_tp_steps[1] = 600.0;   // TP2
      m_tp_steps[2] = 900.0;   // TP3
      m_tp_steps[3] = 1200.0;  // TP4
      m_trade.SetExpertMagicNumber(m_magic_base);
   }
   
   // Idempotent 4-Leg Order Placement with 6-Bar Expiry (30 mins on M5)
   bool Place4LegPendingLimit(string symbol, ENUM_ORDER_TYPE order_type, double entry_price, double total_lot) {
      double leg_lot = NormalizeDouble(total_lot / 4.0, 2);
      if (leg_lot < 0.01) leg_lot = 0.01;
      
      datetime expiry = TimeCurrent() + (6 * 5 * 60); // 30 minutes
      double point = SymbolInfoDouble(symbol, SYMBOL_POINT);
      
      for(int i = 0; i < 4; i++) {
         double sl_price = 0.0;
         double tp_price = 0.0;
         
         if(order_type == ORDER_TYPE_BUY_LIMIT) {
            sl_price = entry_price - (m_stop_loss_pts * point);
            tp_price = entry_price + (m_tp_steps[i] * point);
         } else if(order_type == ORDER_TYPE_SELL_LIMIT) {
            sl_price = entry_price + (m_stop_loss_pts * point);
            tp_price = entry_price - (m_tp_steps[i] * point);
         }
         
         m_trade.SetExpertMagicNumber(m_magic_base + i + 1);
         string comment = StringFormat("GHRv3.1_L%d", i + 1);
         
         if(!m_trade.OrderOpen(symbol, order_type, leg_lot, 0.0, entry_price, sl_price, tp_price, ORDER_TIME_SPECIFIED, expiry, comment)) {
            PrintFormat("[FATAL] Failed to place Leg %d: %s", i + 1, m_trade.ResultRetcodeDescription());
            return false;
         }
      }
      PrintFormat("[SUCCESS] 4-Leg Limit setup placed successfully for %s at %.2f", symbol, entry_price);
      return true;
   }
};
กลับคลังผลงาน