Questions on MQL5 Wizard and standard library of trading classes - page 10

 
Sevrer:

Hello.

I decided to write my own signal module purely for cognitive purposes. I have faced a problem. I have to set pending orders. I have understood that it can be done through CExpertSignal::OpenLongParams(...). But I have a problem - my tester warns about Invalid Expiration. Having dug the source code, I realized that we can't get any type time apart fromORDER_TIME_SPECIFIED and we would like ORDER_TIME_GTC.

I have made a smart move so far, but it's not quite right. I have corrected the function in the library:

What can you advise?

Hello.

You're absolutely right. I didn't take the zero expirations into account.

Your solution is fine. I will make appropriate edits to the Standard Library.

Thank you.

 
uncleVic:

Hello.

You're absolutely right. I didn't take the zero expiry into account.

Your solution is fine. I will make appropriate edits to the Standard Library.

Thank you.

That will be fine, but in the meantime, in this situation I found another way out, the right one :) By creating a class inherited from CExpert, in which I've overridden CheckOpenLong() and CheckOpenShort() functions, and I've made corrections of this kind there:

        if (expiration == TimeCurrent() || expiration == 0)
        {
                m_expiration = 0;
                m_trade.SetOrderTypeTime(ORDER_TIME_GTC);
        }
        else
        {
              if(!m_trade.SetOrderExpiration(expiration))
        	{
         		 m_expiration=expiration;
        	}
        }
 
Sevrer:

But in the meantime, I've found another way out of this situation - the right one :) By creating a class inherited from CExpert, in which I overrode CheckOpenLong() and CheckOpenShort() functions, and made corrections of this kind there:


Inheritance is the right approach.
 

Please explain the logic of the Expert_EveryTick parameter

If Expert_EveryTick=true, the Expert Advisor processes every tick? I.e. it checks entry/exit conditions and position tracking (trawl) on every new tick, right?

And if Expert_EveryTick=fasle - only at the first tick of a new bar? And the trail will also be triggered only at the first tick?

Обработчик события "новый бар"
Обработчик события "новый бар"
  • 2010.10.04
  • Konstantin Gruzdev
  • www.mql5.com
Язык программирования MQL5 позволяет решать задачи на совершенно новом уровне. Даже те задачи, которые уже вроде имеют решения, благодаря объектно-ориентированному программированию могут подняться на качественно новый уровень. В данной статье специально взят простой пример проверки появления нового бара на графике, который был преобразован в достаточно мощный и универсальный инструмент. Какой? Читайте в статье.
 
mr.Taras:

Please explain the logic of the Expert_EveryTick parameter

If Expert_EveryTick=true, the Expert Advisor processes every tick? I.e. it checks entry/exit conditions and position tracking (trawl) on every new tick, right?

And if Expert_EveryTick=fasle - only at the first tick of a new bar? And the trawl will also be triggered only at the first tick?


Yes, you got it right.
 

More questions about the logic of the Expert Advisor:


there is an open position e.g. buy and a fixed lot e.g. 1.

There is a signal to the other side, to sell.

what will the EA do? will be two deals of 1 lot each (the first one will close by 1 lot) or one deal of 2 lots? is there a difference between winning and losing the current buy?


If there is a buy position and again a signal to buy, what methods should I re-define to make it close?

 
mr.Taras:

More questions about the logic of the Expert Advisor:


1. there is an open position e.g. buy and a fixed lot e.g. 1.

there is a signal to the other side, to sell.

what should the Expert Advisor do? will it open two deals of 1 lot each (the first one will close by 1 lot) or one deal of 2 lots? is there a difference if the current buy is in the red or in the plus?


2. the EA will not go long itself, i.e. if there is a buy position and again a signal to buy? which methods should I re-define for it to go long, CheckOpenLong()?


1. Two thresholds of triggering (Expert Advisor settings). If the Close threshold is exceeded, the position simply closes, if two thresholds are exceeded (Close and Open), the position will reverse. -/+ There is no difference.

2. Processing method

 
uncleVic:

1. two trigger thresholds ( EA settings). if the Close threshold is exceeded, the position will simply close. if two thresholds are exceeded (Close and Open), the position will reverse. -/+ There is no difference.

2. Processing method

The Close and Open thresholds are the result of "voting", what do ShortCondition() or LongCondition() in the signals module return?

 
mr.Taras:

Are the Close and Open thresholds the result of "voting" what ShortCondition() or LongCondition() returns in the signals module?

Thresholds are parameters (Signal_ThresholdOpen and Signal_ThresholdClose) against which the result of "voting" is compared.
 

Three questions:

  1. How to make the signal module work only on opening prices and not on every tick?
  2. How do I get the voting values of the signal module in the position tracking module? You need to trawl on an already calculated signal and not make up another signal module to follow.
  3. How to get the voting values of the alarm module in the money and risk management module? You need to open volumes according to the already calculated trading signals, not to compose another signal module for volume calculation.

Theoretically, we can of course build the EA using the wizard and then add all these features manually to the code. But it is desirable that all this was implemented in the form of standard methods, i.e. for dummies who want to use the wizard, so that they don't have to get into the code and edit, for example, if they want to replace one signal module with another.

Reason: