Is it possible to save orders?

 
Hi, When day-trading, pulling orders each evening and reinserting them again in the morning is time consuming.

Although I copy them into excel so that they can be pasted back into a new order ticket, this takes a while, particularly if there are a lot of orders.

In MT5 would it be possible to either:

1. Create an order, save it, delete it and reload it the next day?

or

2. Create and order, pause or freeze (so it is inactive) and then reactivate it the next day?

It would be interesting to hear if anyone has dealt with this problem or has ideas to how it might be overcome.

Thanks
Documentation on MQL5: Trade Functions / OrderGetTicket
Documentation on MQL5: Trade Functions / OrderGetTicket
  • www.mql5.com
Trade Functions / OrderGetTicket - Documentation on MQL5
 
RogH:
Hi, When day-trading, pulling orders each evening and reinserting them again in the morning is time consuming.

Although I copy them into excel so that they can be pasted back into a new order ticket, this takes a while, particularly if there are a lot of orders.

In MT5 would it be possible to either:

1. Create an order, save it, delete it and reload it the next day?

or

2. Create and order, pause or freeze (so it is inactive) and then reactivate it the next day?

It would be interesting to hear if anyone has dealt with this problem or has ideas to how it might be overcome.

Thanks

Are you talking about pending orders ? If yes, it's relatively easy to program your point 1.

I don't think your point 2 is possible.

 
angevoyageur:

Are you talking about pending orders ? If yes, it's relatively easy to program your point 1.

I don't think your point 2 is possible.

Hi Angevoyageur,

Yes, I'm talking about pending orders such as a buy limit.

So to program point 1, would this be achieved with a script?

My understanding would be to create two scripts.

1. That saves all pending orders. (Then I could delete them manually in the Trade panel).

2. That reloads all saved pending orders.

Would that be possible? - If so I'll make a request in the jobs section.

Thanks

Limitless Opportunities with MetaTrader 5 and MQL5
Limitless Opportunities with MetaTrader 5 and MQL5
  • 2012.06.19
  • Anatoli Kazharski
  • www.mql5.com
In this article, I would like to give an example of what a trader's program can be like as well as what results can be achieved in 9 months, having started to learn MQL5 from scratch. This example will also show how multi-functional and informative such a program can be for a trader while taking minimum space on the price chart. And we will be able to see just how colorful, bright and intuitively clear to the user trade information panels can get. As well as many other features...
 
RogH:

Hi Angevoyageur,

Yes, I'm talking about pending orders such as a buy limit.

So to program point 1, would this be achieved with a script?

My understanding would be to create two scripts.

1. That saves all pending orders. (Then I could delete them manually in the Trade panel).

2. That reloads all saved pending orders.

Would that be possible? - If so I'll make a request in the jobs section.

Thanks

Yes it's possible.
 
Roger Hulley:
Hi, When day-trading, pulling orders each evening and reinserting them again in the morning is time consuming.

Although I copy them into excel so that they can be pasted back into a new order ticket, this takes a while, particularly if there are a lot of orders.

In MT5 would it be possible to either:

1. Create an order, save it, delete it and reload it the next day?

or

2. Create and order, pause or freeze (so it is inactive) and then reactivate it the next day?

It would be interesting to hear if anyone has dealt with this problem or has ideas to how it might be overcome.

Thanks

I realize this was posted 10 years ago, but I wonder if you fond how to save your orders?  I have the same problem and can't find how to do it.

 
// Saves pending orders and loads them into the terminal.
#property script_show_inputs

input bool inSave = true; // Save - true, Load - false

#include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006

#define VIRTUAL_SNAPSHOT_REFRESHTIME 1000
#define VIRTUAL_SNAPSHOT_WITHOUT_HISTORY
#include <fxsaber\Virtual\Virtual.mqh> // https://www.mql5.com/ru/code/22577

void OnStart()
{
  if (inSave) // Save
  {
    VIRTUAL::Snapshot(VIRTUAL_SNAPSHOT_REFRESHTIME, -1, false, "");
    VIRTUAL::Save(__FILE__);
  }
  else if (VIRTUAL::SelectByHandle(VIRTUAL::Create(__FILE__))) // Load
    for (uint i = OrdersTotal(); (bool)i--;)
      if (OrderSelect(i, SELECT_BY_POS) && (OrderType() > OP_SELL)) // Pending order
      {
        OrderPrint();

        // If the order does not exist, send the order.
        if (_V(0, !OrderSelect(_V(1, OrderTicket()), SELECT_BY_TICKET, MODE_TRADES) || OrderCloseTime()))
          Print("OrderSend - " +
                (string)!!_V(0, OrderSendAsync(_V(1, OrderSymbol()), _V(1, OrderType()), _V(1, OrderLots()),
                                               _V(1, OrderOpenPrice()), 0, _V(1, OrderStopLoss()), _V(1, OrderTakeProfit()),
                                               _V(1, OrderComment()), _V(1, OrderMagicNumber()), _V(1, OrderExpiration()))));
        else
          Print("Order - exist.");
      }
}

Saves pending orders and loads them into the terminal.