Диалог закрыия позиции

Close Position dialog has next controls:

Ticket

This is a combo box that allows selecting one of ticket from the table of Open position window. In initial state it is the ticket from selected row in the table. If there is no selected row, it is a ticket of first row. There're tickets of all positions in popup list. If there're positions with accounts under margin call or with not tradable currency, their tickets are shown with Gray foreground color. If such ticket is selected, text of combo box is shown with Gray foreground color too. Also button OK becomes disabled. When ticket of position with account not under margin call is selected, which one's currency is tradable, text of combo box is shown with Black foreground color. Also button OK becomes enabled if others controls permit that and the dialog is not disabled consider application state.

Amount

This is a combo box that allows selecting how many lots (contract size) will be closed in position. In initial state it is the amount of positions specified for Currency combo box. This is a maximal amount. There're maximal/lot amounts in popup list, which ones are calculated from maximal amount to 1 lot with step in 1 lot. User can edit selected value manually but he can't input value is not divisible by lot and bigger then maximal.

Rate

This is not editable text field that shows closed price of selected position. The value of field is changed when closed price of selected currency is changed or ticket is changed.

Ok

Is disabled in next cases:

1. In reconnection state.
2. If selected position has account under margin call
3. If selected position has currency is not tradable

When the button is pressed the Close Position Order is created and transmitted to server. But dialog has closed immediately after button is clicked.

As soon as server has admitted order, the position removes from table of Open Position Window in case if selected amount equals amount of position. The account balance in Accounts window is changed and equals sum of previous balance and NetP/L of closed position. In case if amount lower then amount of position, the position isn't removed, the only its amount is changed and is equals subtraction between old value and selected in dialog value. The account balance in Accounts window is changed and equals sum of previous balance and NetP/L of closed position, recalculated by closed amount.