TG Trade Service Manager MT5
- ライブラリ
- Daciana Elena Chirica
- バージョン: 1.0
- アクティベーション: 15
Introducing "TG Trade Service Manager" — your all-in-one solution for seamless trade management in both MQL4 and MQL5 environments. With a focus on speed, reliability, and convenience, this powerful library simplifies the complexities of trade execution and management, empowering developers with a single interface for enhanced efficiency.
Key Features:
-
Unified Interface: TG Trade Service Manager" provides a unified interface for MQL4 and MQL5, streamlining trade management processes across platforms.
-
Error Handling and Logging: Robust error handling and logging mechanisms ensure that both successful transactions and error messages are meticulously recorded, providing developers with comprehensive insights into trade activities.
-
Flexible Stop Loss and Take Profit Options: Developers benefit from flexible stop loss and take profit options tailored to their preferences. With two distinct methods available for setting stop loss and take profit levels, developers can choose between defining prices directly or specifying distances in points. The library intelligently handles computations to place stop loss and take profit orders at the desired distances, eliminating the need for manual calculations and simplifying trade management workflows.
#import "TG_TradeServiceLib.ex5" //or path to library long Buy(double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long Buy(double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL); long Sell(double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long Sell(double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL); long BuyLimit(double price, double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL); long BuyLimit(double price, double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long SellLimit(double price, double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL); long SellLimit(double price, double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long BuyStop(double price, double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL) ; long BuyStop(double price, double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long SellStop(double price, double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL); long SellStop(double price, double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long MarketExecution(int operation, double lots, int stopLossPoints, int takeProfitPoints, string symbol, int magic, string comment = NULL); long MarketExecution(int operation, double lots, double stopLossPrice, double takeProfitPrice, string symbol, int magic, string comment = NULL); bool Close(long ticket, double lots, int slippage); bool Close(long ticket, int slippage); bool CloseBatch(int magic, string symbol, int type = -1); bool DeletePending(long ticket); bool DeleteBatch(int magic, string symbol, int type = -1) ; bool ModifyMarket(long ticket, int stopLossPoints, int takeProfitPoints) ; bool ModifyMarket(long ticket, double stopLossPrice, double takeProfitPrice); bool ModifyMarketBatch(int magic, double stopLossPrice, double takeProfitPrice, string symbol, int type = -1); bool ModifyMarketBatch(int magic, int stopLossPoints, int takeProfitPoints, string symbol, int type = -1); bool ModifyPending(ulong ticket, double stopLossPrice, double takeProfitPrice, double price = 0, datetime expiration = 0); bool ModifyPending(ulong ticket, int stopLossPoints, int takeProfitPoints, double price = 0, datetime expiration = 0); long Pending(int operation, double price, string symbol, int magic, double lots, int stopLossPoints, int takeProfitPoint, string comment = NULL, datetime expiration = 0); #import
BEFORE USING YOU HAVE TO IMPORT THE LIBRARY LIKE MY EXAMPLE ABOVE How to use Examples
//will open a trade with StopLoss = 125 points, TakeProfit = 125 points long resultTicket = MarketExecution( (int)ORDER_TYPE_BUY, // order type 0.01, // lots 125, //stopLoss(in points) 125, //takeProfit(in points) _Symbol, //symbol (optional) 1, //magic number(optional) "MyFirstTrade"); //comment (optional) if(resultTicket <= 0) //usually if execution fails it will result in -1 { //Code to handle failure //return false/Sleep/etc } //Rest of algorithm implementation
Note: I do not use negative values for stopLoss, the library computes everything by itself.
Example 2 using price(double) as parameters:
//will open a trade with StopLoss = 125 points, TakeProfit = 125 points long resultTicket = MarketExecution( (int)ORDER_TYPE_BUY, // order type 0.01, // lots 1.08300, //stopLoss(PRICE) 1.08800, //takeProfit(PRICE) _Symbol, //symbol (optional) 1, //magic number(optional) "MyFirstTrade"); //comment (optional) if(resultTicket <= 0) //usually if execution fails it will result in -1 { //Code to handle failure //return false/Sleep/etc } //Rest of algorithm implementation
Logging Examples
Errors
2024.01.31 18:44:02.346 TradeServiceLibScriptTests (EURUSD,H4) [INFO] | [Trade.mqh::CTrade::CheckStopLossTakeProfitCorrectness] | For order ORDER_TYPE_BUY TakeProfit=-1.08366 must be greater than 1.08469 (Bid=1.08468 + SYMBOL_TRADE_STOPS_LEVEL=1 points)
2024.01.31 18:44:02.346 TradeServiceLibScriptTests (EURUSD,H4) [ERROR] | [Trade.mqh::CTrade::PositionOpen::496] | Invalid stops ORDER_TYPE_BUY MarketPrice: 1.085, Bid:1.08468, Ask:1.08470 SL: 1.08366, TP: -1.08366
INFO:
2024.01.31 18:23:35.607 TradeServiceLibScriptTests (EURUSD,H4) [INFO] | [Trade.mqh::CTrade::OrderSend] | CTrade::OrderSend: market buy 0.01 EURUSD [done at 1.08514]
2024.01.31 18:41:49.329 TradeServiceLibScriptTests (EURUSD,H4) [INFO] | [Trade.mqh::CTrade::OrderSend] | CTrade::OrderSend: market buy 0.01 EURUSD sl: 1.08397 tp: 1.08597 [done at 1.08497]
2024.01.31 18:42:13.301 TradeServiceLibScriptTests (EURUSD,H4) [INFO] | [Trade.mqh::CTrade::OrderSend] | CTrade::OrderSend: market buy 0.01 EURUSD sl: 1.08391 [done at 1.08489]
2024.01.31 18:43:39.998 TradeServiceLibScriptTests (EURUSD,H4) [INFO] | [Trade.mqh::CTrade::OrderSend] | CTrade::OrderSend: market buy 0.01 EURUSD sl: 1.08366 [done at 1.08464]