Need help testing Account and Broker settings in tester (e.g. AccountStopoutMode, AccountFreeMarginMode...)

 

I am sure everyone will agree that it is always a good idea to verify EA sanity in the tester...

Is there a way to configure the tester to simulate various broker settings so I can test my EA's in these different environments? In particular the docs for AccountStopoutMode and AccountFreeMarginMode are so "dry" that IMHO it would make sense for every MQL programmer to write some simple test apps for these functions even if simply to confirm that they work as expected.

So basically - configure the behaviour (in the tester) of functions like AccountStopoutMode, AccountFreeMarginMode, AccountLeverage and MarketInfo with e.g. MODE_MARGININIT, MODE_MARGINMAINTENANCE, MODE_MARGINHEDGED, MODE_MARGINREQUIRED, MODE_SWAPTYPE, MODE_STOPLEVEL, MODE_SPREAD.... there maybe other settings or functions that I can't think of at the moment... you get the idea.

 
4x4ever:

I am sure everyone will agree that it is always a good idea to verify EA sanity in the tester...

Is there a way to configure the tester to simulate various broker settings so I can test my EA's in these different environments? In particular the docs for AccountStopoutMode and AccountFreeMarginMode are so "dry" that IMHO it would make sense for every MQL programmer to write some simple test apps for these functions even if simply to confirm that they work as expected.

So basically - configure the behaviour (in the tester) of functions like AccountStopoutMode, AccountFreeMarginMode, AccountLeverage and MarketInfo with e.g. MODE_MARGININIT, MODE_MARGINMAINTENANCE, MODE_MARGINHEDGED, MODE_MARGINREQUIRED, MODE_SWAPTYPE, MODE_STOPLEVEL, MODE_SPREAD.... there maybe other settings or functions that I can't think of at the moment... you get the idea.


You can configure the Strategy Tester in this way, the best you can do is find a Broker that uses the settings you want to test, open a Demo account with them and then test in the Strategy tester just after yo have connected to them . . . I know, it's poor but it's all we have.
 
RaptorUK:
You can configure the Strategy Tester in this way

ummm... you mean CAN NOT? I understand what you say in the second part but that's not exactly "configure"...
 
4x4ever:

ummm... you mean CAN NOT? I understand what you say in the second part but that's not exactly "configure"...
Oops, yes, in my haste I missed the 't "can't" . . . nope it isn't "configure" by a long way . . . you can make a suggestion to MetaQuotes via the Service Desk. It will probably go the same way as my suggestion to make the Strategy Tester be able to test Indicators correctly like the MT5 Strategy Tester can . . .
 
4x4ever: functions like AccountStopoutMode, AccountFreeMarginMode, AccountLeverage and MarketInfo with e.g. MODE_MARGININIT, MODE_MARGINMAINTENANCE, MODE_MARGINHEDGED, MODE_MARGINREQUIRED, MODE_SWAPTYPE, MODE_STOPLEVEL, MODE_SPREAD.... there maybe other settings or functions that I can't think of at the moment... you get the idea.
I don't use ANY of those. Just free margin check and verify that there will be free margin at the most adverse excursion (i.e. SL) of all open orders so there will not be a stop out (margin call.) See my code's lotsize
 

Yes, I have been looking at it for the past two days... still trying to figure it out... :)


It is true that you can make do without most of these, but at the very least you will probably need AccountStopoutMode and AccountFreeMarginMode. It would be very useful to be able to configure these in the Tester.

 
How can AccountFreeMarginCheck possibly work unless IT already incorporates those things?
 

Ok so if all you are using is AccountFreeMarginCheck then that's great... it will certainly make life easier for you I will need to study your code some more (didn't have time today) to understand how you do that. At the moment it is not clear to me, because the only way I can think of is:

Step 1. get the AcctFreeMarg, based on how many lots you want to open

Step 2. use this value to determine how big a move against you this free margin can sustain?


I can see that it is possible to work out the optimum number of Lots and S/L this way (running this in a loop if necessary and increasing or decreasing values until you get the value that you're happy with) but it looks somewhat cumbersome... when I am using those other functions, I can calculate it at once. On the other hand, if one uses smaller lots then the above two steps would not have to be repeated too many times so that fine.


But like I said - I should probably go look at you're code more closely, it is probably all explained in there, I just had a hard time connecting all the dots... it's a lot of code :) And I nee to apply the "patches" from your other thread...