learn how to earn money villagers [Episode 2] ! - page 275

 
artmedia70:
It is advisable to close the losing ones first, then the profitable ones. Otherwise you might hit a stop-out. Yeah. Exactly. He's covering by means, not by balance.


Thanks for the advice, I'll try it now.


It was like this:

became like this:


 

artmedia70:
It is advisable to close the losing ones first, then the profitable ones. Otherwise you might run into a stop-out. Yeah. Exactly. He's covering by means, not balance.

-----------------------------------------------------------------------------------------------------------------------------------------------

AccountEquity()=AccountBalance()+AccountProfit();

The sum does not change because we transfer some money from the 2nd summand to the 1st summand.

But closing positions with larger lots first makes sense, since losses will be smaller in case of a sudden price reversal not in our favor (when closing a large number of orders). It is also useful to start the process of closing overlapped positions.

 
khorosh:

It is also useful to start the closing process by closing overlapping positions.


The overlapped positions can be closed last, as nothing will change for them anyway.
 
Contender:

The overlapped ones, on the other hand, can be the last to be closed, nothing will change for them anyway.
This is too complicated. We should first determine the ticket of the overlapped orders to leave them for later. And only then we should start to close other orders. Moreover, it is possible that some of these selected blocked orders will only partially cover, so we need to calculate which part of it must be closed in the beginning and which part during the closing of the blocked orders. This is a bullshit mess in general. It is easier to close the overlapped ones at once, and then all the others. But if you like to do everything as best as possible, then please). Personally I don't like to overcomplicate code, if it has no significant effect.
 
khorosh:
This is too complicated. We should then first identify the tickers of the overlapped orders to leave them for later. And only then we should start to close other orders. Moreover, some of these selected blocked orders may only partially cover, so we need to calculate which part of it must be closed in the beginning and which part during the closing of the blocked orders. This is a bullshit mess in general. It is easier to close the overlapped ones at once, and then all the others. But if you like to do everything as best as possible, then please). Personally I don't like to overcomplicate code, if it has no significant effect.


In general, overlapped ones must be closed as soon as they appear. Then there won't be any hassle at all.
 
Contender:

In general, overlapped ones should be closed as soon as they appear. Then there won't be any hassle at all.
I agree, but if the author doesn't want to. As they say, the free will. Perhaps, the trailing stop is used because it may occur when the trend is moving sideways and both lock orders are successfully closed with profit.
 

Thanks to everyone who helped to improve the closing, the chart is more beautiful)

Closing orders in the order they were opened.

//+------------------------------------------------------------------+
//|                 Закрыть все ордера                               |
//+------------------------------------------------------------------+


double ClossAllOrders ()

{
  for(int i=0; i<OrdersTotal(); )
  {
    if ( !OrderSelect(i, SELECT_BY_POS) )
      break;
    
    int type   = OrderType();

    bool result = false;
    
    switch(type)
    {
      //Close opened long positions
      case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 3, Lime );
                          break;
      
      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 3, Lime );
                          break;

      //Close pending orders
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }
    
    if(result == false)
    {
      Print("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      i++;
      Sleep(500);
    }  
  }
}

// End
 
BeerGod:

Thanks to everyone who helped to improve the closing, the chart is more beautiful)

Closing orders in the order they were opened.

I would like to thank all of you who have helped me to improve the chart. For investors who do not understand, on the contrary, PAMM show spikes upwards, as if not a failure of the deposit, but on the contrary, spikes upwards.

 
khorosh:

What makes it more beautiful, before the peaks were up, now they are down. For investors who do not understand PAMM, on the contrary, there are pictures with peaks upwards, as if not failures of the deposit, but on the contrary, jumps upwards.


Well, the dips after the upwards peaks they may perceive as a series of losses, but first down and then up in a couple of seconds while the grid is closing, how quickly everything is repaid and with a profit)
 
BeerGod:

Well the dips after the peaks up they may perceive as a series of losses, but so first down and in a couple of seconds up while the net is closing, how quickly everything is beaten off and with a profit)

It's all bullshit.

Reason: