Developers! Do you even test what you create? - page 9

 
Mikalas:

C-4 In my opinion, getting operational information is much more

more interesting than history. We need to know two things about the instrument:

1. warrants.

2. Position

It seems to me that it is much more important to analyse the trades, because they are at the lowest level and you can know the orders and positions by them, but the opposite is not true. But the opposite is not true.

In your case, OnInit() is executed once at the beginning of the program. But there must be only one block of checks. It synchronizes the state of the EA with the current situation. And it doesn't matter where the new data has come to it, from the orders history at the moment of initialization, from the history at the moment of execution or from the event OnTradeTransaction. The result must be identical, because there is only one block responsible for it, too.

 

Vasiliy - this is a 'primitive' piece of code.

It's simple - you take an order and then work with it....

my_order = temp_order;

One line!

 
papaklass:

Is the OnTradeTransaction event even needed in its current form?

It turns out that it isn't, since we still have to take information from the history.
 

Mikalas:

I just noticed that the product MUST be tested (I'm testing it on MY own dime)!

i'll assume that's going off topic.

so what, you give me the magazine and the code?

i'm in the mood to help here.

 
C-4:
It turns out that it isn't, since we still have to take information from the history.

Oh, my God! Is it valid in the history?

papaklass probably meant that OnTradeTransaction returns errors?

 

sergeev ->I'm in the mood to help here.

Sorry, but I don't need any help.

 
Mikalas:

sergeev ->I'm in the mood to help here.

Sorry, but I don't need any help.

why do you have to drool for 9 pages?
 
Mikalas:

Vasiliy - this is a 'primitive' piece of code.

It's simple - you take an order and then work with it....

One line!

It's not a question of one line or a hundred. It's about the approach. A.k. Here's the code as an example to see what I mean. It's guaranteed to keep track of new orders coming in with or without TradeTransaction event, whether it's an initialization or a new order coming in:

/*Какое бы событие не наступило, оно будет обработано OnRefresh()*/

OnInit()
{
    OnRefresh();
}

void OnTimer(void)
{
    OnRefresh();
}

void  OnTradeTransaction(
      const MqlTradeTransaction&    trans,
      const MqlTradeRequest&        request,
      const MqlTradeResult&         result
   )
{
     OnRefresh();
}

///
/// Следит за поступлением новых трейдов и ордеров.
///

void OnRefresh()
{
    HistorySelect(0, TimeCurrent());
    for(; ordersCountNow < HistoryOrdersTotal(); ordersCountNow++)
    {  
       printf(HistoryOrderGetTicket(dealsCountNow));
    }
}

///
/// Текущее количество ордеров.
///
int ordersCountNow;
 
papaklass:

That's what I'm talking about.

Why isn't this OnTradeTransaction separated into separate events:

- OnOrderCreate //issue an order;

- OnOrderModify // modification of an active order;

- OnOrderDelete //delete the order;

- OnPositionOpen //open position;

- OnPositionModify //set/modify stops, change of position volume;

- OnPositionClosed //closing a position using a Stop Loss or Market Order;

and so on.

With this approach, the trader will subscribe to and handle the events that interest him.

I do get all the events I'm interested in, there's a division there!
 

C-4, will be processed, of course, but why is OnRefresh() needed?

Everything is shared in OnTradeTransaction(). I have no shortage of information.