Structure rules. Learning how to structure programmes, exploring possibilities, errors, solutions, etc. - page 16

 
As you might expect, everyone has their own structure and understanding of how things should be. ))
 
tol64:
As you might expect, everyone has their own structure and understanding of how things should be. ))
Exactly, that's why I propose to give up this argument, as we won't come to any consensus anyway. I suggest that we go back to discussing the general principles of programming large projects.
 
C-4:
No, no and again no!!!!!!!!!!!!!!!! By that logic, a simple strategy flip on a moving average is also MM. Why, it was +1 contract and became -1.

:)

My colleague tried to explain to you how the EA can be conveniently structured (module names are conventional, of course). Instead of playing with terminology (which is not important), try to check this structural division. It is quite convenient and productive.

Picture. The arrows show the movement of information:


 
C-4:
Exactly, so I suggest that we stop arguing about this, because we won't come to a consensus anyway. I suggest that we go back to discussing the general principles of programming large projects.
It seems that one of these principles is being discussed, when applied to trading projects (to the basic logic of their creation).
 
MetaDriver:

...

Kartinko. The arrows show the movement of information:

That's a much clearer way to look at thoughts. Everything is clear even without words. Otherwise, these endless blah-blah-blah are very difficult to digest sometimes. )) And after the scheme you can ask qualifying questions. I do not have them yet. ))

 
MetaDriver:

:)

My colleague tried to explain to you how the EA can be conveniently structured (module names are conventional, of course). Instead of playing with terminology (which is not important), try to check this structural division. It is quite convenient and productive.

The arrows show the movement of information:

Yeah, I can see that. Only the complexity is not given anywhere but delegated to the recommendation corrector and the market driver. Under this scheme, the corrector has to dig into the trading history of the TS and understand for it what its actual state is. The market driver still has to correctly identify the current position of the strategy and correct it, and in netting, this is not easy.
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Позиционирование графика
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Позиционирование графика
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Позиционирование графика - Документация по MQL5
 
tol64:

That's a much clearer way to think about things. Everything is clear even without words. Otherwise, these endless blah-blah-blahs are very hard to digest sometimes. )) And after the scheme you can ask qualifying questions. I do not have them yet. ))

Here is the answer whether you have to draw a picture to understand the task :)

MetaDriver:

:)

(The module names are of course relative.) Instead of playing with terminology (which is not important), try to check this structural division. It is quite convenient and efficient.

The arrows show the movement of information:


Where is the trawl there? I take it it's in the MM block, because it needs a directional forecaster.

Or is it still in the market driver? because you need the current pose to trawl.

I would add a volatility predictor and one more block to correct protective stops, namely protective stops because (imho) exit by TP or SL is force majeure for a normal TS.

 
Urain:

So that's the answer to whether you need to draw a picture to understand the task :)

Where is the trawl? I think it's in the MM block, isn't it?

or in the market driver? After all, you need the current position for the trawl.

I would add a volatility predictor and one more block to correct protective stops, exactly protective because (imho) exit by TP or SL is force majeure for a normal TS.

And then a few more blocks and the strategy will start to bump... If at the very beginning there are absolutely reasonable questions in which block to describe one part of the strategy and which in the other, then it means that the scheme is not unambiguous, and this leads to what problems is known.
 

Now that we've started drawing schematics, here's my improved one. I hope it will be clearer than the previous one:

BENEFITS

  • There are only two modules.
  • The links are clearly defined and unambiguous.
  • Any class that describes 4 methods can be a trading strategy
  • Description of all rules is always stored in one place: trading strategy class. There is no need to search through the entire project for some "volatility module".
  • The number of strategy states is a constant. Under no rules of the TS, it cannot be larger. There can't be any additional modules and they are simply unnecessary
  • All common entities can and must be described in the base class of control*.

*Thus, the "Exit at the end of trading session" rule, which is universal for all strategies, can be described in the base class. If this rule is set, the base class will call the support method of closing the position at the end of the day instead of calling it once again. And the position will be closed at the right time, even if this is not specified in the basic strategy's rules.
 
C-4:

Yeah, I can see that. Only the complexity is not given anywhere, but delegated to the recommendation adjuster and the market driver.

That's fine. The goal was not to eliminate objective difficulties, but not to create new ones.


According to this scheme, the adjuster has to dig through the trading history of the TS and understand for it what its actual state is.

I think we already found out that TS has no state (memory). The corrector does not have to dig the history either. It was inserted into scheme on purpose by your request - I do perfectly well without it... ))


The market driver still has to correctly identify the current strategy position and adjust it, and in netting, that's not easy.

:)

Do I have to take your word for it?

double CMarketDriver::GetCurrentPos(string Sym)
  {
   if(!PosInfo.Select(Sym)) return 0; // DBL_MIN;
   double v=PosInfo.Volume();
   return(PosInfo.PositionType()==POSITION_TYPE_SELL) ? -v : v;
  }
bool CMarketDriver::Synhronize(const SymbolPos  &sp,int  &Err)
  {
   Err=0;
   bool res=true;
     {
      SymInfo.Name(sp.Sym);
      SymInfo.Refresh();
      double fp= TranslateLots(sp.Pos);  // Приводит рекомендованную в процентах от депо позу к рыночным лотам для данного инструмента
      double cp=GetCurrentPos(sp.Sym);
      double pos=fp-cp;   // вычисляет разницу текущей и рекомендованной позы
      if(pos>0.000001)
         res=Trade.Buy(NolrmalizeLots(pos),sp.Sym);  // "обналичивает разницу"
      if(pos<-0.000001)
         res=Trade.Sell(NolrmalizeLots(pos),sp.Sym);  // "обналичивает разницу"   
     }
   return res;
  }