[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 361

 
costy_ писал(а) >>

Help

int Minute( )
It returns the current minute (0,1,2,...59) of the last known server time at the moment of program start (this value does not change during program execution).

Note: in testing, the last known server time is simulated.

But in the indicator, when tested, the last known server time is not simulated, is it supposed to be?

It is simulated in the indicator, if the indicator is called from the Expert Advisor in the tester or optimizer mode. If it is in visual mode, the real time is taken.

 

Going to Minsk on the next train....

Here, estimate wrote a block of approximate control of the level of Equity in the area where I drained with the control gives a profit of 100% of the depo for 4 months

Look it up if you don't mind correctly there...

 

Any other thoughts on how to improve

Seems like a promising advisor, what do you think??????

 
Vinin >> :

The indicator is also modelled if the indicator is called from an EA in tester or optimiser mode. If in visual mode, the real one is taken.

It's a pity, what is a simple way to make the function work once a day in an indicator (tester)?

 

It is required to close a part of an open position (20, 30, 50, etc. %).

This requires that the remaining part of the lot meets the broker's requirements:

- At one broker - minimum lot and step: 0.1 and 0.01 respectively.

- At another broker - 0.01 and 0.01

- The third broker has 0.1 and 0.1.


Does anyone have any idea how to perform the check in the easiest way?

 
chief2000 >> :

It is required to close a part of an open position (20, 30, 50, etc. %).

This requires that the remaining part of the lot meets the broker's requirements:

- At one broker - minimum lot and step: 0.1 and 0.01 respectively.

- At another broker - 0.01 and 0.01

- The third broker has 0.1 and 0.1.


Does anyone have any idea how to perform the check in the easiest way?





1. We may open X (0,15 etc.) in the same direction. We obtain ~0,25 (0,3 or whatever is necessary ... ) in total. - open in the other side as many orders as we would like... then close several orders.

2. how can one close more orders from below the plinth?

3. no way.

 
chief2000 писал(а) >>

It is required to close a part of an open position (20, 30, 50, etc. %).

This requires that the remaining part of the lot meets the broker's requirements:

- At one broker - minimum lot and step: 0.1 and 0.01 respectively.

- At another broker - 0.01 and 0.01

- The third broker has 0.1 and 0.1.

Does anybody have any idea how to check in the easiest way?

The easiest option.

1. We calculate the necessary fraction (which must remain after closing). 2.

2. subtract from the received number of the minimum lot

3. round off this difference to the required accuracy.

4. add the minimum lot.

We have obtained the position size after closing it.

If needed in the code, I will do it later.

The algorithm will be fully usable and can be used practically with any brokerage company.

 
BARS >> :

1. We can open X (0.15 etc.) in the same direction. - open in another direction as many orders as we would like... then close several orders.

2. How may I close more from below the plinth?

3. no way.

I`m afraid the opening of new orders will make everything more complicated :)

 
Vinin >> :

The easiest option.

1. Calculate the required share (which should remain after closing)

2) subtract the minimum lot from the obtained number

3. round off this difference to the required accuracy.

4. add the minimum lot.

We have obtained the position size after closing it.

If needed in the code, I will do it later.

The algorithm is quite usable and can be used practically with any brokerage company

The percentage (20, 30, 50, etc.) is set beforehand, at least for now.

The question is mainly about definition of "required accuracy" based on broker's requirements for min. lot and step (at the same time

the universality of the solution). Suppose 25% position needs to be closed with 0.72 lots: 0.01 step and 0.1 lot minimum.

 
chief2000 писал(а) >>

The percentage (20, 30, 50 etc.) is set in advance, at least for now.

The question is mainly about defining the "required precision" based on the broker's min. lot and pitch requirements (so that there is

the universality of the solution). Suppose I want to close 25% of a position with 0.72 lots: a step of 0.01 and minimum lot 0.1.

extern double CloseProcent=20.0; // Заданный процент лота для закрытия

//=====================================================================
// Функция для расчета закрываемой доли позиции с учетом минимального |
// лота и шага                                                        |
// На входе размер позиции, на выходе закрываемая часть               |
//---------------------------------------------------------------------
//                        Copyright © 2009, Victor Nicolaev aka Vinin |
//                                              e-mail: vinin@mail.ru |
//=====================================================================
double CalculateCloseLots(double LotSize){
   double LotMin  = MarketInfo(Symbol(), MODE_MINLOT);
   double LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
   
   double Res;
   
   Res= LotSize*(100.0- CloseProcent)/100.0;   // Считаем сколько должно остаться
   Res-= LotMin;                              // Убираем миниальный лот
   Res=MathRound( Res/ LotStep)* LotStep;       // Округляем до заданой точности 
   Res+= LotMin;                              // Получаем размер позиции после закрытия
   Res= LotSize- Res;                          // Считаем размер к закрытию
   return( Res);
}

Something like this has worked out for me.

Reason: