Discussion of article "Universal Expert Advisor: CUnIndicator and Use of Pending Orders (Part 9)"

 

New article Universal Expert Advisor: CUnIndicator and Use of Pending Orders (Part 9) has been published:

The article describes the work with indicators through the universal CUnIndicator class. In addition, new methods of working with pending orders are considered. Please note: from this point on, the structure of the CStrategy project has undergone substantial changes. Now all its files are located in a single directory for the convenience of users.

The screenshot below shows a test fragment of CIpmulse 2.0 in the strategy tester. It shows the placed pending orders and the work with them:


Fig. 1. Working with pending orders during the test of the Impulse 2.0 strategy

Author: Vasiliy Sokolov

 

It's just awesome! I'm talking about the indicator wrapper

The only thing I personally lack in your wonderful universal Expert Advisor is the possibility to work on FORTS on one account with many different Expert Advisors, i.e. to keep track of positions by Expert Advisors by magic, not by standard means.

Therefore, for the time being I am using my own solutions

 
Viktor Vlasenko:

It's just awesome! I'm talking about the indicator wrapper

The only thing I personally lack in your wonderful universal Expert Advisor is the possibility to work on FORTS on one account with many different Expert Advisors, i.e. to keep track of positions by Expert Advisors by magic, not by standard means.

Therefore, so far I am using my own solutions

For this purpose there is HedgeTerminal, which API is integrated with the universal Expert Advisor by the way. By the way, the universal expert was originally created as a wrapper for HedgeTerminal. But in order to popularise the engine, I detached it from HT and started to develop it as an independent project.

 
Vasiliy Sokolov:

For this purpose there is HedgeTerminal, API of which by the way is integrated with the Universal Expert Advisor. By the way, the universal expert was originally created as a wrapper for HedgeTerminal. But to popularise the engine, I untied it from HT and started to develop it as an independent project.

thanks, I read about HedgeTerminal - it is redundant for my needs, and I don't want to work with someone else's closed tool.

and I really like the change of file-folder structure in the current version.

 

What do you mean by universal expert? I think we started with the fact that it is both for MT4 and MT5. But it is not compiled for MT4 and its libraries are all in MQL5.

 
void CUnIndicator::PushName(string name)
{
   int old_size = ArraySize(m_params);
   int size = ArrayResize(m_params, ArraySize(m_params) + 1);
   for(int i = 0; i < old_size; i++)
      m_params[i+1] = m_params[i];
   m_params[0].type = TYPE_STRING;
   m_params[0].string_value = name;
}

I suspect that here the whole m_params array is clogged by the first parameter applied to it

 

void CUnIndicator::PushName(string name)
{
int old_size = ArraySize(m_params);
int size = ArrayResize(m_params, ArraySize(m_params) + 1);
for(int i = 0; i < old_size; i++)
m_params[i+1] = m_params[i];
m_params[0].type = TYPE_STRING;
m_params[0].string_value = name;
m_params_count++;
}

It seems to me that it should be like this, pay attention to m_params_count++; we increase the size of the array of passed parameters, so we increase the counter of passed parameters, at least when calling the indicator without parameters it worked like this. In other cases, it seems that the last parameter was not perceived at the start of the indicator.

 

Yes, and in the same function:

For(int i = old_size-1; i >= 0; i--)
m_params[i+1] = m_params[i];

 

Nice article.

When the Create method in the CUnIndicator class is used for a customer-defined indicator, that code has a call to PushName(), which is a buggy function.

When creating a user-defined indicator, the first element of the MqlParam parameters_array[] must hold the name of the custom indicator.

All elements must be moved one position to the right to free up element 0 for the custom indicator name.

Modify the following:

void CUnIndicator::PushName(string name)
{
   int old_size = ArraySize(m_params);
   int size = ArrayResize(m_params, ArraySize(m_params) + 1);
   //for(int i = 0; i < old_size; i++) m_params[i+1] = m_params[i]; // it's wrong to write it this way
   for(int i=old_size-1;i>=0;i--) m_params[i+1] = m_params[i]; //That's right.
   m_params[0].type = TYPE_STRING;
   m_params[0].string_value = name; // Customised indicator name
   m_params_count++;// Number of parameters plus one 
}
 
Question to the author: Give me a direction: how to make indicators called via CUnIndicat loadable?
 

Good day.

Question to the author: the latest version of the trading engine attached to the article has been downloaded, the attached strategy Impluse 2.0 is being tested.

1. In the strategy tester in the visualisation mode, should the trading modes control panel work?

2. Should the trade modes set via the TradeState.SetTradeState method be executed ?

When trading on the account, the panel works and modes are switched, but in the strategy tester it does not.