Discussing the article: "Developing a multi-currency Expert Advisor (Part 2): Transition to virtual positions of trading strategies" - page 2

 
Yuriy Bykov #:

I have not considered this option yet, but I will keep in mind that it is also possible. However, if I manage to find a good set of ready-made Expert Advisors from the market, how can I use them together? Do I just run the whole set with the selected MM parameters?

Yes.

 

Yuriy Bykov #:

I'm used to the MT5 trading functions.

I am good at them, but I gave up on them for this reason.

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "Developing a multicurrency Expert Advisor (Part 2): Moving to virtual positions trading strategies"

fxsaber, 2024.02.07 01:03 pm

Carefully approach the choice of trading API for virtual trading. Choose from the available ones. It is logical to give preference to the API, on which it is as easy as possible to program the TS. I don't really understand the common practice of all trading platforms to invent their own bicycle - trading API. To endow it with OOP-entities "out of the box", etc. In this sense, MQ went a good way - all APIs without OOP.

 
fxsaber #:

The concept itself is good for real trading. But there for the synchroniser you will have to keep the history of virtual trading. A lot of things. A serious path, to put it mildly.

Here I don't understand why for real trading you would have to keep a virtual trading history. Perhaps we have a slightly different interpretation of "virtuality". I just haven't encountered the need to keep a history, as I always have virtual positions synchronised with real ones, and there is no possibility to switch off synchronisation for a while (not yet?).

 
Where can I get the EA file to test it?
 
fxsaber #:

Architecturally, the virtualisation would be decoupled from the TC.

That is, the TS uses ordinary trading functions like OrderSend(), and we use our library to override them to use virtual positions?

 
fxsaber #:

Carefully choose a trading API for virtual trading. Choose among the available ones. It is logical to give preference to the API on which it is as easy as possible to program the TS.

I have seen that in fact since the end of 2021 I have already used my API for virtual trading of my TS. Of course, I have got used to implement everything I need on it, using only two common methods for positions and pending orders - Open() and Close().

Once again I am sorry that I did not find your Virtual library in time )

 
summertop #:
Where can I get the EA file to test?

There is a list of attached files at the end of the article

 
Yuriy Bykov #:

Here I didn't understand why you would have to keep a virtual trading history for real trading. Perhaps we have a slightly different interpretation of the concept of "virtuality". I just haven't encountered the need to keep a history, as I always have virtual positions synchronised with real ones, and there is no possibility to switch off synchronisation for a while (not yet?).

Example.

  1. Synchronised virtual and real with one position and its takeout.
  2. The tick has reached the takeout: in the virtual position it has triggered, in the real position - the takeout re-jack (limiter).

It is impossible to close a real position with a market order because there are no positions in the virtual market (e.g. rollover, huge slip on a market order).

The price did not touch the takei again, but went in the opposite direction. It would seem that it is possible to keep a take take on the history of a closed position in a virtual account. But the price may never reach it. Then by what levels should we synchronise?

And then there appears a virtual terminal that always trades - it has a signal kernel. And it is needed only to close positions that are hung on the real.

In general, it's a big topic. I have three virtual kernels for synchronisation with the real:

  1. The kernel that trades with time constraints - does not synchronise with the real.
  2. BestInterval is pushed to the first virtualisation. - It is synchronised with the real to open positions.
  3. The kernel that trades without time constraints (always in trade) - synchronised with the real for closing positions.

 
Yuriy Bykov #:

That is, the TS uses normal trading functions like OrderSend(), and we use our library to override them to use virtual positions?

Yes, this principle does not require rewriting anything in the TS, because the TS does not know where it trades. Its code is not changed so that it can trade in different virtual or real.

 
fxsaber #:

The inputs are a good example. Each input parameter should be written five or six times.

I made refactoring by inputs. Some resulting code pieces for the example.

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit() {
   expert = new CAdvisor(new CVolumeReceiver(magic_));

   // Добавляем один экземпляр стратегии
   expert.Add(new CSimpleVolumesStrategy( symbol_, inStrategyInput + inSimpleVolumesStrategyInput));

   return(INIT_SUCCEEDED);
}
   InputBase.fixedLot = NormalizeDouble(0.01 / 0.16 * depoPart_, 2);
   const double Array0[] = {13, 0.3, 1.0, 0, 10500, 465, 1000, 3};
   strategies[0] = new CSimpleVolumesStrategy("EURGBP", InputBase + Input[Array0]);
//+------------------------------------------------------------------+
//| Конструктор                                                      |
//+------------------------------------------------------------------+
CSimpleVolumesStrategy::CSimpleVolumesStrategy( string p_symbol, const string sInputs ) : CStrategy(p_symbol, sInputs)
{
   this.Input = sInputs;

   ArrayResize(m_orders, this.Input.maxCountOfOrders);

   // Загружаем индикатор для получения тиковых объемов
   iVolumesHandle = iVolumes(m_symbol, this.InputStrategy.timeframe, VOLUME_TICK);

// Устанавливаем размер массива-приемника тиковых объемов и нужную адресацию
   ArrayResize(volumes, this.Input.signalPeriod);
   ArraySetAsSeries(volumes, true);
}
Files: