, and it was necessary to organise traversal of all positions and select a position by index in the list of positions, something like this (this is just an example):
//+------------------------------------------------------------------+//| Calculate positions Buy and Sell|//+------------------------------------------------------------------+void CalculatePositions(int &count_buys,int &count_sells)
{
count_buys=0.0;
count_sells=0.0;
for(int i=PositionsTotal()-1;i>=0;i--)
if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY)
count_buys++;
if(m_position.PositionType()==POSITION_TYPE_SELL)
count_sells++;
}
//---return;
}
To make it work fully on both types of accounting (stock and hedge), it is necessary to make many changes in the Expert Advisor code, not only in the section with trailing stop.
On netting mode accounts at 2 brokers (BKS-Forex and Roboforex) during testing (settings and testing parameters are attached)
trailing stop on the red line (history and operations - in the appendix) is performed on teeth[5] contrary to the trailing stop on teeth[0] stated in the Expert Advisor code.
teeth[0].
However, when trading on a demo account of Roboforex and BKS-Forex, the trailing stop is still trawled by teeth of the current bar.
But when trading on the real account of BKS-Forex, stops again "go" to teeth[5].
On netting mode accounts at 2 brokers (BKS-Forex and Roboforex) during testing (settings and testing parameters are attached)
trailing stop on the red line (history and operations - in the appendix) is performed on teeth[5] contrary to the trailing stop on teeth[0] stated in the Expert Advisor code.
teeth[0].
However, when trading on a demo account of Roboforex and BKS-Forex, the trailing stop is still trawled by teeth of the current bar.
But when trading on the real account of BKS-Forex, stops again "go" to teeth[5].
It should not be like this.
It is normal there. The red line from 5 to 0 bar has a straight line - trawl on teeth[0]. And on your two extreme drawings - there is also the closing of the current candlestick with the crossing of the red line - exit from the position.
Let's say that I got my hands to modernise the Expert Advisor for hedge accounts
I also made some changes
5 bars trall analyses only AO without AC when taking into account the trend on the alligator (so it seems to work better).
Alligator indicator is initialised with shift parameters from the settings to make it clearer in the visual testing mode .
with all variants of fractions disabled, there could be cases when the trawl triggers and a new entry on the trend could be by the fractal "cancelled" earlier by the price - I eliminated this situation.
I ask all those who are not indifferent to check what has turned out and give their comments.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
and log
Incorrect algorithm for traversing all positions - the position was selected by SIMPLE:
, and it was necessary to organise traversal of all positions and select a position by index in the list of positions, something like this (this is just an example):
incorrect position modification algorithm - the position was selected by SIMBOLE
and the position should have been selected by ticket:
Waiting for the author to make corrections.
The Expert Advisor was developed and accordingly the article was designed when hedge accounts for mt5 were not even dared to be mentioned.
Therefore, position selection was realised by symbol.
The Expert Advisor was developed and accordingly the article was designed when hedge accounts for mt5 were not even dared to be mentioned.
That's why position selection was realised by symbol.
Hedge accounts are already a year old. Therefore, please make all the changes that I mentioned above.
To make it work fully on both types of accounting (stock and hedge), it is necessary to make many changes in the Expert Advisor code, not only in the section with trailing stop.
I will do it as soon as possible.
On netting mode accounts at 2 brokers (BKS-Forex and Roboforex) during testing (settings and testing parameters are attached)
trailing stop on the red line (history and operations - in the appendix) is performed on teeth[5] contrary to the trailing stop on teeth[0] stated in the Expert Advisor code.
teeth[0].
However, when trading on a demo account of Roboforex and BKS-Forex, the trailing stop is still trawled by teeth of the current bar.
But when trading on the real account of BKS-Forex, stops again "go" to teeth[5].
It should not be like this.
Hi. I've compiled the code and tried to use it in the tester, but no operation occurs. What should I change in the parameters? Thank you.
On netting mode accounts at 2 brokers (BKS-Forex and Roboforex) during testing (settings and testing parameters are attached)
trailing stop on the red line (history and operations - in the appendix) is performed on teeth[5] contrary to the trailing stop on teeth[0] stated in the Expert Advisor code.
teeth[0].
However, when trading on a demo account of Roboforex and BKS-Forex, the trailing stop is still trawled by teeth of the current bar.
But when trading on the real account of BKS-Forex, stops again "go" to teeth[5].
It should not be like this.
It is normal there. The red line from 5 to 0 bar has a straight line - trawl on teeth[0]. And on your two extreme drawings - there is also the closing of the current candlestick with the crossing of the red line - exit from the position.
Good afternoon.
Let's say that I got my hands to modernise the Expert Advisor for hedge accounts
I also made some changes