Clearing in the tester - page 3

 
Roman Shiredchenko #:

interesting....

will have to ponder.... indeed the opening price of a position after clearing - "jumps"... :-)

I didn't know that...

That's what I was trying to say from the beginning :)

 
JRandomTrader #:

That's what I've been trying to say all along :)

Yes, I realised that before. But the question is that the clearing was deducted from the balance, but the tester was not. In other words, in the tester he simply "overslept" and that was it. And in the real - already a loss on the balance current.

it seems that on the real will need to count the transfer to BU taking into account the write-off on clearing - and of course from the price of the current price of the total position in points, so that the final volume, even if the wing in BU + a few points, that was the final close in the plus!

 
Roman Shiredchenko #:

But the question is that the clearing was deducted, but the tester was not. In other words, in the tester he just "overslept" and that's all. And in the real - the current balance loss.

This is a feature of futures trading. And this is taken into account when closing the position.

And when determining the BU, you just need to look at the initial opening price of the position.

 
JRandomTrader #:

This is a feature of futures trading. And it will be taken into account when closing a position.

1. But in determining the BU, you just have to look at the initial opening price of the position.

I see, but not quite yet... ...thank you.

1. you mean right after the opening or after the addition to the existing one? Before clearing?

 
JRandomTrader #:

This is a feature of futures trading. And it will be taken into account when closing a position.

But when you define a Buy, you just have to look at the initial opening price of the position.

This is more logical and simpler than what I suggested.

 
Roman Shiredchenko #:

I see, but not quite yet... sps.

1. do you mean immediately after opening or topping up the existing one? Before clearing?

At every topping up, recalculate the new effective opening price taking into account the old price and transaction volumes. And disregard clearing.

Approximately like this:

new position price = ( old position price * old position volume + new transaction price * new transaction volume ) / ( old position volume + new transaction volume )

 
Aleksandr Slavskii #:

Yes, it makes more sense and is simpler than what I suggested.

But there is one subtlety here. You need to remember this initial price, including when reinitializing the robot, when restarting MT or the entire computer.

Perhaps, global variables of the terminal will work here, but every time I change the robot, it writes its own status file. At the same time, a lot of other things are written there as well - SL and TP levels, a lot of statistics...

And also each robot writes its own log, sort of:

2021.11.03 22:44:26
TradeRes=1520.0 GlobalRes=25220.0 Min=-1180.0 Max=29600.0
MaxDrawdown=5900.0 MaxRestore=30780.0 GlobalVolume=56.0
SumProfit=35500.0 SumLoss=-10280.0 P/L=3.45
SumLongProfit=29300.0 SumLongLoss=-3200.0 P/L_Long=9.16
SumShortProfit=6200.0 SumShortLoss=-7080.0 P/L_Short=0.88
Stat: ProfitTrades=9 LossTrades=5 LongTrades=7 ShortTrades=7
ProfitLongTrades=6 LossLongTrades=1 P/L_LongTr=6.00
ProfitShortTrades=3 LossShortTrades=4 P/L_ShortTr=0.75
AvrProfit=3944.4 AvrLoss=-2056.0 MaxProfit=12840.0 MaxLoss=-3200.0
AvrLongProfit=4883.3 AvrLongLoss=-3200.0 MaxLongProfit=12840.0 MaxLongLoss=-3200.0
AvrShortProfit=2066.7 AvrShortLoss=-1770.0 MaxShortProfit=2580.0 MaxShortLoss=-2620.0

 
Aleksandr Slavskii #:

This is more logical and simpler than what I suggested.

JRandomTrader #:

Every time you refill, recalculate the new effective opening price, taking into account the old price and transaction volumes. And disregard the clearing.

Approximately like this:

new position price = ( old position price * old position volume + new transaction price * new transaction volume ) / ( old position volume + new transaction volume )


Colleagues spas, there in principle it is possible not to calculate it - the opening price - it itself is averaged - it is considered at refilling of contracts?

I.e. after topping up - to request the opening price of the position and that's it... It has to be up-to-date....

Now we are clearing and the data is as follows:


t. really got some money thrown in.... :-)

But also the opening price was moved to the level of the existing price of the instrument. I managed to close two contracts myself from the terminal - in the sell - in the profit:

From about the top red line there were 7 contracts to the sell - I closed two to the profit and wondered what to do next...


"Whenever you add a trade, you should recalculate the new effective opening price taking into account the old price and the volumes of the trades. And disregard clearing. "

So you can essentially ignore it at all?

And so it will not be, that at transfer in the BU + 30 points for example of the former sell, after clearing and recalculation of the opening price - it will be already not BU + 30 points, but it will be already minus for example -10 points from the new opening price?

Is it possible?

And the final close of this SL will be in the loss....

And then at the next recalculation during clearing - will something be recalculated and the final price will be calculated as planned?


here is the picture now - these trades are partly from the terminal on the market wing sell total of 12 contracts:


 

Here they are in total for today's clearing (two clears on the plus side) - from the highlighted line + there were two buoy closes - below on the plus side of 1 contract of the total NELL position of 7 contracts:


 
JRandomTrader #:

But there is one subtlety here. You need to remember this initial price, including when reinitialising the robot, when restarting MT or the whole computer.

Global variables of the terminal might be suitable here, but in my case each robot writes its own status file with each change. At the same time, I also write a lot of other stuff here, like SL and TP levels, a lot of statistics...

Really simple, and most importantly reliable.


If you forgive me for being off-topic, but maybe you have a recipe for defining when clearing is over?

The problem is this: broker opener, during clearing deletes pending orders, and the clearing field does not set them again.

I don't know about futures, but on stocks clearing ends at different times.

So, I have not been able to determine the moment when clearing ends for a specific security.

I simply use timer to send order placement until it opens.

I don't like this approach, and I don't have another one.