Clearing in the tester

 
Comments not related to "New MetaTrader 5 build 3091: Performance improvements" have been moved to this topic.
 

Colleagues, was wondering what topic to write in - decided to write here - please help to report data and how to work with it, namely to take into account clearing costs in the tester - here is for example data where synchronisation is not counted in the test:


i.e. also a set of sell position on the market

but for real - report - variation margin closed (i.e. collated - and there were no loss-making closures, upon open positions the interim variation margin was taken at the moment of clearing, also upon set up of robot (and hands) sell position:


question - how to take it into account in the tester, as in the tester how to take it into account (can - somewhere - set it to count, because there is a discrepancy between these deductions - in the tester they are not - on the real - there is...

How to bring it all together so that everything is uniform (or as uniform as possible...)


I.e. in the tester the current loss is clear:


but it is not removed by clearing... when the final price is above the opening price of the final position...

and it is clear then when going to profit and transferring to the + side everything is closed in profit:



but on the real - when variation margin is closed in minus at clearing - already at this transfer to breakeven + already minus has been closed and the final close if a bundle of contracts in profit, then all the same the final is closed in minus.

How can this issue be solved to take into account clearing and synchronization when they write off the minus intermediary?

How to calculate the closing amount of variation margin in the tester for clearing? (at least roughly and roughly estimate)

In other words, how to take into account in the tester, closing in minus variation margin for clearing (as in the real account)? To objectively calculate a transfer to breakeven of an aggregate position?

In general, we need solutions for the correspondence of calculations of all COMMITS and others in real and in the tester ... if not absolute, then how to optimally count them programmatically - also withdrawal at the close variation margin for clearing? At least approximately, with what - that is acceptable tolerance ... to understand was - for example in my case - to correctly calculate the final accumulated position when transferring it to Breakeven, so it was at Breakeven + (as the tester), but not minus (as in reality now) due to withdrawal of intermediate closing variation margin for clearing.


P.S. As a result, it does not count in the tester: it does not close or open variation margin (as in the real - report) - how to count it, at least approximately in the tester to match the real and the tester:


 
Roman Shiredchenko #:

The writing is not very clear.

I can assume the problem is that after clearing, it's not the original opening (set) price of the position, but the clearing price?

And the question is how to simulate this in the tester?

 
If possible make forward-testing tasks for agents at least in smaller batches (not to say about equal distribution between agents), otherwise agents may drop out or not immediately connect to main computer (with delay), and some agents may receive 2000 tasks and some do not get at all (or in the process they disconnect, drop out for unknown reason) most agents just idle and there is a long wait. agents who received the job finish the package, it can take more than a day because the history is long, and one optimization instead of 50 hours goes 250 or more, I think it is also true for the use of cloud agents, I once tried them also constantly falling off and joining, in the back test no such problems.Thank you very much in advance, this will help a lot as there is a lot to optimise with forward 1\2 1\3.
 
Roman Shiredchenko #:

I still don't really get it.

Roughly speaking, the essence of clearing comes down to the fact that part of the profit/loss is accrued/written off before the actual position is closed, and a new "opening price" is set for the position, taking this accrual/written off into account. All the same, the amount of profit/loss of clearing and closing the position will be the same (roughly).

Clearing as such does not interfere, but "Balance" type trades are very confusing.

 
Roman Shiredchenko #:

Profit on clearing + profit on closing the position on the real = profit in the tester. "Profit" has a sign everywhere.

Although, imitation clearing may be necessary for correct calculation of the free margin. But then one has to imitate both "Correction" and "Balance", which is unrealistic, IMHO.

 
JRandomTrader #:

Still don't really get it.

Roughly speaking, the essence of clearing comes down to the fact that part of the profit/loss is accrued/written off before the actual position is closed, and a new "opening price" is set for the position, taking this accrual/written off into account. All the same, the amount of profit/loss of clearing and closing the position will be the same (roughly).

Clearing as such does not interfere, but "Balance" type trades are very confusing.

JRandomTrader #:

Profit on clearing + profit on position close on the real = profit in the tester. "Profit" has a sign everywhere.

Although, imitation clearing may be necessary for correct calculation of free margin. But then one has to imitate both "Correction" and "Balance", which, IMHO, is unrealistic.


I mean what you can't understand, or I just don't get it - I mean what I mean because of such a labyrinth:



and two lines below where -303 there is a difference between the data in the tester and in the real !!!!!!!

I have not noticed any change in the opening price after these deductions from the balance.

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

P.S. If you can not in the tester is similar to display or account, then I'll be in the real world to read data on these losses (advise variant) and when transfer SL in small profit will take into account these write-offs....

I will write here a little code later.... So far I will just check the printout on the real ... Prints.

That I transfer stop loss for example by 30 pips to profit and if I have it closed then the TOTAL balance amount becomes BIGGER than the size of write-offs such intermediate: variation margin close, as now, for example.

If I set SL + 30 pips from the opening price - then there will be a profit 30 * 1 ruble from the contract * 12 contracts = 360 rubles - closing in profit, but I had yesterday was written off the balance -700.00 rubles and above!!!! So the final close will be negative!!!!!!!!!!!!!!!

The question is that in the tester - all in the plus!!!! how to take it into account in the tester? So that even if there were differences - minimal!!!!!!


What am I trying to say?

That in the end the tester works like this:


The real with the same parameter values works like this:

at the expense of the variation margin for the day - going down from the entry point of a set of these 12 contracts:


Now the data is exactly 6983 - 6949 = 34 pips. If they are multiplied by the number of contracts in the market 12 contracts * 34 = 408, which shows in the tab TOOLS - current profit loss!


So if I somewhere - somewhere here - on the red arrow - converted SL in profit - on the green arrow - THEN I LOSE IN GENERAL MINUS: -700 + 400 = -300 RUB. Somewhere around -300.00 RUB:


And in the tester there would have been a drawdown on equity, which in fact was repaid and all!!!!!!!!!!!!! and the final close would have been in PLUS AND ALL!!!!!!!!!!!

In the real world the minus would be, for instance, due to write-offs: the daily margin close was 700 roubles. How it is better to take it into account (in real it is clear possible - I count data from history of transactions - I will compare - it works - not, but in the tester - HOW????????????????????????

How to match real and tester????????????

How in the tester to enter the account and these expenses???????????????

In this tab of the tester NONE ( or I have not found such settings to take into account!!!!! )


In general, I need help on how to properly account write-offs during the day from the balance, for example, at clearing???? To bookmark and account them before closing the position!!!!!!!!

 
Roman Shiredchenko #:


Right now the data is absolutely correct - 6983 - 6949 = 34 pips. If we multiply it by the number of contracts in the market - 12 contracts * 34 = 408 RUR, which is shown in the tab TOOLS - current profit loss!


So if I somewhere here - on the red arrow - converted the SL into a profit - on the green arrow - I would have closed into a total loss: -700 + 400 = -300 RUR. Somewhere around -300.00 RUR:


So, let's ponder on where the opening price 6983 is coming from, if the order is opened, as it is shown in the screenshot:

sell 2 6861

sell 2 6876

sell 2 6896

sell 2 6922

sell 2 6986

sell 2 6976


2 modders: cut off post 148 into a separate thread, it doesn't belong here.

 
JRandomTrader #:

So I suggest to ponder on where the opening price of 6983 is coming from, if the position was set, judging by the screenshot:

sell 2 6861

sell 2 6876

sell 2 6896

sell 2 6922

sell 2 6986

sell 2 6976


2 modders: cut off post 148 into a separate thread, it doesn't belong here.

OK, I got it. I.e. the final price was higher on the real - due to the write-off from the clearing balance....

How then to properly count and more - less with the tester to bring?

P.S. About clearing - still to read...

 
Roman Shiredchenko #:

OK, I get it. I.e. the final price is higher on the real - due to the deduction from the balance by clearing....

How then correctly to count and more - less with the tester to bring?

P.S. About clearing - still reading...

I'm too lazy, I suggest you calculate on your own:

As I pointed out, closing of the position - at what price it was really closed.

The open position - at the price of the last clearing, close the position - at which it was closed realistically, plus the results of all clearing on this position

and compare.

 
Roman Shiredchenko #:

In general, we need help on how to properly account write-offs during the day from the balance, for example, at clearing???? To bookmark them and take them into account before closing the position!!!!!!!!

In the Strategy Tester you can't do anything.

You may try to change the working principle of trawl/stop in your EA, as I see it works on a total profit.

I do not remember exactly, but deals closed at clearing differ from those closed by your EA. Look at what it says in OnTradeTransaction().

And then you can adjust your total trawl/stop by amount of trades closed at clearing.

I don't understand what I'm trying to tell you, but I can't formulate it.

Reason: