Code Library / Trade Management

Order Manager Class

OOP order management with retry logic.

Language: MQL5 · Category: Trade Management · Tags: order management, OOP, MQL5

Source code

#include <Trade/Trade.mqh>
class COrderMgr{
   CTrade t;
public:
   bool Buy(double lots,double sl=0,double tp=0){
      for(int i=0;i<3;i++){if(t.Buy(lots,_Symbol,0,sl,tp))return true;Sleep(1000);}
      return false;
   }
};

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own MQL5 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.

Related snippets