The task of searching for orders - page 14

 
Dmitry Fedoseev:
I'm not OTK:) Test on orders in the tester or on a demo account.
What is GTC ?
 
Suppose the second highest price order goes first, it is remembered in price_max, then the first one, replaced by price_max, the second order is lost,
 
Vladimir Pastushak:
What is QA ?
The Technical Control Department.
 
Vladimir Pastushak:

It turns out that to avoid redundancy in 99% of cases you must still write all code manually...

Well, I'm talking about adequate balance, and you can't avoid redundancy in TRANSFORM code at all. I stopped on such a matryoshka of 3 structures

struct ORDER {
        double          d_Price;
        double          d_Lot;
        double          d_Profit;
        string          s_Comment;
        datetime        t_Time;
        int                             i_Ticket;
        int                             i_Op_Type;
};
struct ORDERS_GROUP {
        double  d_Lots_Total;           // сумма лотов
        double  d_Profit_Total;         // суммарная прибыль
        double  d_BreakEven_Price;      // уровень б/у
        ORDER           o_Lowest;       // параметры нижнего ордера
        ORDER           o_Highest;      // параметры верхнего ордера
        ORDER           o_Oldest;       // параметры старейшего ордера
        ORDER           o_Newest;       // параметры новейшего ордера
        int             i_Orders_Total; // кол-во ордеров
};
struct ALL_ORDERS {
        int      i_Orders_Total;        // кол-во ордеров
        double   d_Lots_Total;          // сумма лотов
        double   d_Profit_Total;        // суммарная прибыль
        double   d_BreakEven_Price;     // уровень б/у
        double   d_One_Point_Price;     // прибыль одного пункта
        datetime t_Data_Collected;      // время последнего обновления данных
        bool     b_Changed;             // была операция после последнего обновления данных?
        ORDERS_GROUP    o_Buy;          // сводка данных ордеров Buy
        ORDERS_GROUP    o_Sell;         // сводка данных ордеров Sell
        ORDERS_GROUP    o_Buy_Stop;     // сводка данных ордеров BuyStop
        ORDERS_GROUP    o_Sell_Stop;    // сводка данных ордеров SellStop
        ORDERS_GROUP    o_Buy_Limit;    // сводка данных ордеров BuyLimit
        ORDERS_GROUP    o_Sell_Limit;   // сводка данных ордеров SellLimit
        ORDERS_GROUP    o_Market;       // сводка данных рыночных ордеров
        ORDERS_GROUP    o_Pendings;     // сводка данных отложенных ордеров
};
ALL_ORDERS go_Orders;

It is filled in during one pass, it is updated when the bot makes a transaction or the number of orders changes. The redundancy is on the edge here, I think. It is enough for me in 90% of cases but it doesn't solve your problem; you need a separate function

 
Dmitry Fedoseev:
Suppose the second highest price order goes first, it is stored in price_max, then the first order is overwritten by price_max and the second order is lost,

no, we do not lose the second order; the maximum order is written first

                  if(op>price_max) // Самый верхний ордер
                    {
                     price_max=op;
                     m_tick_upper=tc;
                    }

If the second order is higher, it is overwritten if it is lower, then the second condition works

                  if(tc!=m_tick_upper) // Предпоследний верхний ордер
                     if(op>price_max2)
                       {
                        price_max2=op;
                        m_tick_upper_=tc;
                       }

the ticket is checked, if it is not the maximum but the top one, then it is the top one before the maximum one.

 
Alexander Puzanov:

Well, I'm talking about adequate balance, and you can't avoid redundancy in TRANSFORMAL code altogether. I settled on such a matrix of 3 structures

It is filled in during one pass, updated when the bot makes a deal or the number of orders changes. The redundancy here is too much for me in 90% of cases but it doesn't solve your problem; you need a separate function

So, you put two structures in a third ...

Your method of filling all structures is interesting ...

 
Dmitry Fedoseev:

There is no quicker way. If you want faster, you need to think about the whole EA algorithm, maybe you can get rid of the need to look for two low, two high on every tick.
I must admit that your method of searching for orders is more stable than mine in some cases, now I'm running tests and depending on the order opening position your method works without errors... My method does not work correctly in some cases...
 
Vladimir Pastushak:
I must admit that your method of finding orders is more stable than mine in some cases, now I'm doing tests and depending on the order opening position your method works without errors... My method does not work correctly in some cases...

I wrote about this yesterday. Depends on which order was opened.

 
Dmitry Fedoseev:

I wrote about this yesterday. Depends on the order in which you opened it.

Yes yes yes, only I didn't pay much attention to it...
Reason: