Discussion of article "Expert Advisor based on the "New Trading Dimensions" by Bill Williams" - page 4

 
natyog:
and log

Incorrect algorithm for traversing all positions - the position was selected by SIMPLE:

void C_TS_BW::TrailingStop(void)
  {
   bool select=pos_info.Select(m_Symbol);

, 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 properties
         if(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;
  }


incorrect position modification algorithm - the position was selected by SIMBOLE

bool  PositionModify( 
   const string  symbol,     // symbol 
   double        sl,         // Stop Loss price 
   double        tp          // Take Profit price 
   )

and the position should have been selected by ticket:

bool  PositionModify( 
   const ulong   ticket,     // position ticket 
   double        sl,         // Stop Loss price 
   double        tp          // Take Profit price 
   )
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением...
 

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.

 
Alexey Klenov:

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.

 
How does the trawl work? Stop loss on the red line of the alligator is trawled (teeth)?
 
natyog:

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

  • 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.
Files: