Trade Manager
-
Is it possible to create a Trade Management EA, that removes all limitOrders 6minutes before red news and add them back 6minutes after news and that will remove stop
losses and TakeProfits
if there are existing trade(s) 6minutes before the red news?If yes, how to do it?
-
For 1 order or many?
-
@jstap Many
-
Try this, I haven't tested it, AI has written the code: https://fxdreema.com/shared/BIQYITMQd
You will have to set the times but this should add replace orders back onto your platform
The next pictures and text will show you how to create on FX:
// ---- OnTick Function ----(for this is the main settings section)
{
ReopenLastDeletedOrders();
}
// ---- Global Variables and Includes ----
#include <Trade/Trade.mqh>
int PCLOSE = 10;
CTrade trade;
// ---- Custom Function Section ----
void ReopenLastDeletedOrders()
{
HistorySelect(0, TimeCurrent()); // Select all historical orders
int totalOrders = HistoryDealsTotal();
int count = 0;for (int i = totalOrders - 1; i >= 0 && count < PCLOSE; i--) { ulong ticket = HistoryDealGetTicket(i); if (ticket > 0) { int orderType = HistoryDealGetInteger(ticket, DEAL_ENTRY); double volume = HistoryDealGetDouble(ticket, DEAL_VOLUME); double price = HistoryDealGetDouble(ticket, DEAL_PRICE); double sl = HistoryDealGetDouble(ticket, DEAL_SL); double tp = HistoryDealGetDouble(ticket, DEAL_TP); string symbol = HistoryDealGetString(ticket, DEAL_SYMBOL); ENUM_ORDER_TYPE pendingType; if (orderType == ORDER_TYPE_BUY_LIMIT) pendingType = ORDER_TYPE_BUY_LIMIT; else if (orderType == ORDER_TYPE_SELL_LIMIT) pendingType = ORDER_TYPE_SELL_LIMIT; else if (orderType == ORDER_TYPE_BUY_STOP) pendingType = ORDER_TYPE_BUY_STOP; else if (orderType == ORDER_TYPE_SELL_STOP) pendingType = ORDER_TYPE_SELL_STOP; else continue; // Skip non-pending orders MqlTradeRequest request; MqlTradeResult result; ZeroMemory(request); request.action = TRADE_ACTION_PENDING; request.type = pendingType; request.symbol = symbol; request.volume = volume; request.price = price; request.sl = sl; request.tp = tp; request.deviation = 10; request.type_filling = ORDER_FILLING_IOC; request.type_time = ORDER_TIME_GTC; request.comment = "Reopened Order"; if (OrderSend(request, result)) { Print("Reopened order: ", result.order); count++; } else { Print("Failed to reopen order: ", result.comment); } } }}
To create a block click on custom then create custom block

Settings (on tick) is at the top, includes & global variables is at the bottom, custom functions is on the lower right



-
@jstap Thank you so much for your efforts. I appreciate it alot.
-
