Discussion of article "Universal Expert Advisor: the Event Model and Trading Strategy Prototype (Part 2)" - page 4

 
Andrey Khatimlianskii:
At the very least, analyse the price. Maybe you don't need to enter at all.
Yes, there is such a mechanism. And where should it be built in, if not in the class of trade orders? And how to formalise such a mechanism, what sharp movement should be considered critical?
 
Гога:
Yes, there is such a mechanism. And where should it be built in, if not in the class of trade orders? And how to formalise such a mechanism, what sharp movement should be considered critical?

Well, that's the question! That is why it is not built into the engine.

For one strategy a slip of 20 pips does not matter, and you should enter anyway, while for another strategy a slip of 2 pips breaks all the statistics, and you should not enter worse.

And what should a universal trading engine do for these two strategies? Right, return the requote price and let the trading logic make a decision.

Well, or add a customisation. More precisely, settings for all cases of life )

 
This is a very good article. I have learned a lot. Good contribution, thanks.
 
Alain Verleyen:

On build 1241, the code is compiling well, so I tried to run a backtest. It doesn't take any trades.

After digging a bit  I found it's due to filling mode. The mode allowed on the broker/symbol I am using is ORDER_FILLING_IOC. Your TradeCustom class set the filling mode by default to ORDER_FILLING_FOK. And I am stick there, how can change this filling mode for the Agent.mq5 EA to take trade ? I could search, it will take me a lot of time.

That's the problem with such tools, very similar to MQL5 wizard EA from Metaquotes, it's almost unusable for anyone who doesn't know all the details of the classes. Once you face an issue which was not provided by the author it becomes a real pain to fix it or modify/add to it. I don't see any real difference between your solution and the one from Metaquotes (wizard).

Anyway, congratulations for the huge work. It is a great programming work.

There are some classes in MetaEditor5 include folder. If some one can give us a deep explain of Expert folder classes, it will be very helpful, because they looks very complicated. People like to write standard EA based on formal base classes and not always re-create wheels.... Anyway, this article helps a lots for not re-create wheels.
 
Amy Liu:
There are some classes in MetaEditor5 include folder. If some one can give us a deep explain of Expert folder classes, it will be very helpful, because they looks very complicated. People like to write standard EA based on formal base classes and not always re-create wheels.... Anyway, this article helps a lots for not re-create wheels.
I do agree. The problem is when there is a bug in the framework. Before using a framework we should either decide to learn it deeply or to be sure it's well supported by the author.
 
Alain Verleyen:
I do agree. The problem is when there is a bug in the framework. Before using a framework we should either decide to learn it deeply or to be sure it's well supported by the author.
This is why I want to learn classes in MetaEditor5, they're from "government". ;)
 
Amy Liu:
This is why I want to learn classes in MetaEditor5, they're from "government". ;)
And bugged and not well supported :-D
 
thanks.Very good article.
 

Mr Vasily,

very nice code... and useful to me...

in the mt5 news builds (1952), we got a "message" in the compiler,


bool CBarDetector::IsNewBar(void)

  {

   datetime time[];

   if(CopyTime(m_symbol, m_timeframe, 0, 1, time) < 1)return false;

   if(time[0] == m_last_time)return false;

   return (m_last_time = time[0]);    //<=============HERE

  }

//+------------------------------------------------------------------+

///////////MESSAGE in THE METAEDITOR compiler///////////////
expression not boolean NewBarDetector.mqh 87 24


the correct should be this? please confirm

//+------------------------------------------------------------------+
//| Returns true if for the given symbol and timeframe there is |
//| a new bar.|
//+------------------------------------------------------------------+
bool CBarDetector::IsNewBar(void)
  {
   datetime time[];
   if(CopyTime(m_symbol, m_timeframe, 0, 1, time) < 1)return (false);
   if(time[0] == m_last_time)return (false);
   return (m_last_time == time[0]);
  }
//+------------------------------------------------------------------+



 

Hi Vasiliy,

Please pardon me for asking a question on your article this far down after you wrote it. I'm only going through the articles properly now in search of alternatives to a framework. Something has struck me as odd, very likely due to my misunderstanding.

With regards to New Tick and New Bar event handlers. You loop through the list of added ticks, then build the event structure, passing it to Init and Support event handlers, e.g. new tick event below:

//+------------------------------------------------------------------+
//| Detects the arrival of new ticks of multi-instruments.           |
//+------------------------------------------------------------------+
void CStrategy::NewTickDetect(void)
  {
   if(m_ticks_detectors.Total()==0)
      AddTickEvent(ExpertSymbol());
   for(int i=0; i<m_ticks_detectors.Total(); i++)
     {
      CTickDetector *tick=m_ticks_detectors.At(i);
      if(tick.IsNewTick())
        {
         m_event.period=PERIOD_CURRENT;
         m_event.type=MARKET_EVENT_TICK;
         m_event.symbol=tick.Symbol();
         CallSupport(m_event);
         CallInit(m_event);
        }
     }
  }

In one of your examples, e.g. moving average clip below;

bool CMovingAverage::IsTrackEvents(const MarketEvent &event)
  {
//--- We handle only opening of a new bar on the working symbol and timeframe
   if(event.type != MARKET_EVENT_BAR_OPEN)return false;
   if(event.period != Timeframe())return false;
   if(event.symbol != ExpertSymbol())return false;
   return true;
  }

This IsTrackEvents function seems to nullify the purpose of NewTickDetect function above! So the Moving Average example above should be able to trade on multiple instruments based on its ability to check multiple symbols as in the NewTickDetect, but the IsTrackEvents allows trading only for the Strategy timeframe & Symbol (symbol being key here). Does this not mean that the NewTickDetect loop is not really required, as the strategy can only trade on its symbol? In effect the new tick detect should only check if the received tick is of the strategy symbol - without looping. Which in effect is similar to having a strategy object for each symbol of interest, which the CStragyList loops over?

I sure hope that I'm making sense, and hope that you can clarify this for me.

I love your work. I have learn't a lot from your articles, so a great many thanks.

Kind regards,

Shep