now closes ALL opposing positions when a position is opened.
current price acquisition has been moved inside the PlacesBuy and PlacesSell functions to protect against gaps and slippages.
InOnTradeTransaction pending orders are placed in a while loop - so to say, we are beating the server to the punch :) - It is not the best solution but it will stay for now.
Actually, now we can think:
What is the best way to increase positions (lot volume calculation)?
What to do with the opposing positions
How best to increase position (lot volume calculation) - no way, adding lots, this is a pyramid, this is different, the lot should remain constant.
What to do with the opposite positions - Close as is.
I recommend adding this indicator to the "tester.tpl" template:LifeHack Balance Equity, then the tester will immediately show changes in balance and funds. Approximately like this:
... connect the template and pass the input parameters to the EA class
Done, connected.
Sometimes there are too many parameters. Recently, I've become lazy. I do it this way because I do not need to bother with passing parameters to the EA. What are the disadvantages?
inputdouble LotSize = 0.1;
inputint SL = 500;
inputint TP = 300;
//другие входные переменные#include <AvLib\ClassEA.mqh> // тут лежит класс советника
CClassEA MyEA;
While the Expert Advisor is working, data is written to the array in OnTradeTransaction. The recording format is as follows: if a Buy position is opened, we record "+1"; if a Sell position is opened, we record "-1".
For instance:
Buy - we record "+1".
Buy - we record "+1".
Buy - we record "+1".
Sell - we record "-1".
When testing is completed, the array data is processed in OnTester and written to the csv file. The file is created ina shared folder of all client terminals \Terminal\Common\Files. The name of the file is formed as follows:
then the extension "csv" is added to the file name:
int filehandle=FileOpen(file_name+".csv",FILE_WRITE|FILE_CSV|FILE_COMMON);
Algorithm of array processing: if current record is the same direction as previous one (it corresponds to opening several positions of one direction in a row) - then we increase counter by one, if current record is opposite to previous one (it corresponds to reversal of position direction) - then we assign counter value "1" to it.
The resulting csv file is easy to process in Excel:
step one: left click on the column with the data
step two: insert recommended chart
These are the statistics (for step "35" and step "65"):
practically 50% of all cases are when the length of uninterrupted trades equals "1". In other words, we have situations such as: we opened Buy and then reversed the position (i.e. closed Buy with a loss and opened Sell) or this situation: we opened Sell and then reversed the position (i.e. closed Sell with a loss and opened Buy). Thus situations with uninterrupted trades of length "1" are a guaranteed loss.
Approximately 25% of all cases with the length of uninterrupted trades equaling "2", by the following example: we opened Buy, then opened another Buy and reversed the position (i.e. closed two Buy and opened Sell - resulting in a loss equal to zero).
I think these most numerous categories (length of uninterrupted trades equal to "1" and "2") must be thought over in more detail in order to correct the strategy of placing Stop pending orders.
Version 1.003:
Actually, now we can think:
I recommend adding this indicator to the "tester.tpl" template:LifeHack Balance Equity, then the tester will immediately show changes in balance and funds. Approximately like this:
Feito. Conecte o Vault, atualize os arquivos do projeto do Vault.
Hi Vladimir, can you add me please? thank you so much.
Hi Vladimir, can you add me please? Thank you so much.
Done, added it.
The plan is to make statistics like this: how many positions of one direction are open in a row before the flip.
For example: #1 Buy, #2 Buy, #3Buy and #1Sell -> close all Buy positions. So the statistics will be: three positions.
... connect the template and pass the input parameters to the EA class
Done, connected.
Sometimes there are too many parameters. Recently, I've become lazy. I do it this way because I do not need to bother with passing parameters to the EA. What are the disadvantages?
Vladimir, can you hook me up, please?
While the Expert Advisor is working, data is written to the array in OnTradeTransaction. The recording format is as follows: if a Buy position is opened, we record "+1"; if a Sell position is opened, we record "-1".
For instance:
When testing is completed, the array data is processed in OnTester and written to the csv file. The file is created ina shared folder of all client terminals \Terminal\Common\Files. The name of the file is formed as follows:
then the extension "csv" is added to the file name:
Algorithm of array processing: if current record is the same direction as previous one (it corresponds to opening several positions of one direction in a row) - then we increase counter by one, if current record is opposite to previous one (it corresponds to reversal of position direction) - then we assign counter value "1" to it.
The resulting csv file is easy to process in Excel:
step one: left click on the column with the data
step two: insert recommended chart
These are the statistics (for step "35" and step "65"):
Vladimir, can you hook me up, please?
Done. Added (didn't see the post right away, missed it).
The current list of connected users to the project:
For step 35, extended totals:
Here we can see that
I think these most numerous categories (length of uninterrupted trades equal to "1" and "2") must be thought over in more detail in order to correct the strategy of placing Stop pending orders.