Useful tips for participants in the Championships - page 11

 
VNIK писал (а):

Sorry for the indiscreet question to the Championship organisers:

How will the taxation of the prize be handled (because the amount of each prize is very big):

Will each prizewinner have to pay his/her own tax? (and at what rate?) Or will it be centralized? ( i.e. taxes are already taken into account?).

It would be a shame to give up half the prize for taxes!

I agree with you, I too would be sorry to give half your prize to pay my taxes...
Actually, it's better not to win at all so you don't feel sorry... .
 
VNIK:

Sorry for the indiscreet question to the Championship organisers:

How will the taxation of the prize be handled (because the amount of each prize is very big):

Will each prizewinner have to pay his/her own tax? (and at what rate?) Or will it be centralized? ( i.e. taxes are already taken into account?).

It would be a shame to give up half the prize for taxes!


Yes, prizewinners pay their own taxes - this is standard practice for prizes all over the world.
 
There is no way to test whether this closing of orders will always work correctly:
while (OrdersTotal()>0)
   {
      OrderSelect(0,SELECT_BY_POS);
      if (OrderType()==OP_BUY)       OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
      else if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
      
      err=GetLastError();
      if (err==135 || err==138) RefreshRates();
   }
The question is: If the error code is not 135 or 138, will there be a loop? If so, how can this be avoided, with a guarantee that the orders will close?
 
MAEstro:
There is no way to test whether this closing of orders will always work correctly:
There's error after error here. I have counted 4 errors and they are all catastrophic.
Read the advice article again, please.
 
I remember this advice by heart, but it seems to be of little use :(

Gross neglect of error control with looping
(I have error control, pending orders are not used, or should I make a loop exit condition as well? What to do then with order close guarantee? Or maybe I have not processed all error codes?

Lack of control of OrderSelect - asynchronous processes in action
(yes, I don't check what Order_Select returns! Well let's say if in this particular case it returns false, what will change inside the loop, or what will be incorrect? I'm not modifying the order, I'm closing it!)

Skipping market environment refresh function through RefreshRates()
(I think I refresh it, everything should be ok here)

Maybe there is a ready piece of code for closing of ALL orders? I would appreciate it if you could post it!

P.S. what Rosh suggested http://www.alpari-idc.ru/ru/experts/articles/9.html , does not guarantee to close orders!
 
There are even 5 errors:
  1. OrderSelect result is not checked
  2. the result of OrderClose() is not checked explicitly
  3. GetLastError() can be called without any trade operations (for example, if you have encountered a pending order)
  4. RefreshRates() is called not always, but only when there is a failure - this is a gross error
  5. if there are pending orders in the list, this is a 100% loop
As a result: there are 5 errors in 9 lines - the code can only be thrown out.
 
Renat:
Even 5 errors:
  1. OrderSelect result is not checked
  2. the result of OrderClose() is not checked explicitly
  3. GetLastError() can be called without any trade operations (for example, if you have encountered a pending order)
  4. ...
As a result: there are 5 errors in 9 lines - the code can only be thrown out.
And why cram it all into an expert for the competition? To read the log?
The OrderSelect should select and the OrderClose should close the necessary orders.
And there should not be any errors :-)
Or at the client's expense :-)
 
Renat писал (а):
There are even 5 errors:
  1. OrderSelect does not
  2. explicitly
  3. check the result
  4. OrderClose()
  5. GetLastError() may be called without any trade operations (for example, if a pending order is encountered)
  6. RefreshRates() is not always called, but only on failures - a gross error
  7. if the list contains pending orders, then 100% looping
As a result: there are 5 errors in 9 lines - the code can only be thrown out.

Objective: close all orders with a 100% guarantee
Restrictions: pending orders are not used

1. Why should we check the result if we need to close an order? If it returns false, it will return to it in the next pass, since a while loop is used.
2. See point 1.
3. There is a check for error codes for this purpose.
4. If updating always, then there is no point in checking for errors :(
5. No pending orders

All the examples of order closing I found in my search are single-pass and only work if all is well with the server, there are no requotes etc. And they all lead to the fact that one day an order will not close and we will get a good profit... If I'm wrong, correct me, or give me a link where I can be convinced I'm wrong.

Of course I am well aware that my code may lead to a loop, but in my opinion it is better than the risk of not closing an order, which could lead to serious financial losses.
Although it would be better if all orders were closed with 100% guarantee and there is no chance of an order loitering, this is the code I would like you to give me =)

Here is a slightly modified code, which should even consider pending orders:
while (OrdersTotal()>0)
   {
      OrderSelect(0,SELECT_BY_POS);
      if (OrderType()==OP_BUY)       OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
      else if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
      else OrderDelete(OrderTicket());
      
      RefreshRates();
      err=GetLastError();
      if (err!=135 && err!=138 && err!=0) break;
   }

It's not as "reckless" as the previous one?
I still don't understand, why check OrderSelect and OrderClose in this case?
 
Unfortunately, no one will give any guarantees on trading operations. The above code is much better than the previous one.

OrderSelect must always be checked, this is explicitly stated in the Useful Tips:
  • Lack of control of OrderSelect - asynchronous processes in action


    Usually a trader perceives his programme as single-tasking and the only one. But in reality, there are a lot of asynchronous changes in the trading account right during the Expert Advisor's operation. Positions are modified, added and deleted. If the result of each OrderSelect() call is not controlled, then it may happen that at a certain moment the expert will operate with wrong (zero) data and make a wrong move.

 
Renat:
Unfortunately, there are no guarantees on trading operations. The above code is much better than the previous one.

OrderSelect must always be checked, this is explicitly stated in the Useful Tips:
  • No control of OrderSelect - asynchronous processes in action

    ... Positions are modified, added and removed. ...

Suppose a position is modified. There is a request to select an order by some condition. An error occurs. What may be changed? The initial conditions may not be available on the next tick, so why should I make the same error again?
No comment on "added and removed" :-(
Please give me a working example of code using OrderSelect to get OrderCloseTime.
Reason: