TG Trade Service Manager MT4
- Bibliotecas
- Daciana Elena Chirica
- Versión: 1.0
- Activaciones: 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.ex4" //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 19:10:12.684 TradeManagerUnitTests EURUSD,H4: [INFO] | [Trade.mqh::CTrade::CheckStopLossTakeProfitCorrectness] | For order ORDER_TYPE_BUY TakeProfit=-1.08800 must be greater than 1.08506 (Bid=1.08506 + SYMBOL_TRADE_STOPS_LEVEL=0 points)
2024.01.31 19:10:12.684 TradeManagerUnitTests EURUSD,H4: [ERROR] | [Trade.mqh::CTrade::SendOrder::205] | Invalid stops ORDER_TYPE_BUY PendingPrice: 1.08510, Bid:1.08506, Ask:1.08510 SL: 1.08300, TP: -1.08800
INFO:
2024.01.31 19:09:19.733 TradeManagerUnitTests EURUSD,H4: [INFO] | [Trade.mqh::CTrade::SendOrder] | Success >>> Send >>> Symbol[EURUSD], Volume[0.01], Operation[0], PriceOpen[1.08511], SL[1.08300], TP[1.08800]
2024.01.31 19:09:55.496 TradeManagerUnitTests EURUSD,H4: [INFO] | [Trade.mqh::CTrade::SendOrder] | Success >>> Send >>> Symbol[EURUSD], Volume[0.01], Operation[0], PriceOpen[1.08511], SL[1.08386], TP[1.08636]