Questions on OOP in MQL5 - page 76

 
awsomdino:

The example should be taken from Saber, I don't know the true purpose of it, but I saw his if else) trees there to get what you need. When I came here, I had a question, how to do it right away, and look for how to implement it, re-read everything - really lost only time, there is no correct implementation, heaps of articles and everywhere his own. I'm really disappointed when you don't understand much about the code and stand on the crossroads of 5 roads and think which way to go. It's not even a question of whether you'll find a profitable trading system here, the question is whether you'll find the right optimal way here) - This is our dear MQL5.

Well, he's saying openly that you should always look for a profitable TS, look for instruments where you can apply the TS, and you have to search fast.

And in the signals his TS showed results, then stopped working, then he turned on the TS again (I suspect he re-opted it with new parameters), TS went up again, then stopped working again

If this functionality is flexible and allows you to quickly optimize and search for tools to apply - then you have everything you need

but look for a single EA, which will be tested on all available history on one specific tool.... well i've already done that, i don't think there's anything there

 

Igor, we're talking about code here)

and i don't like his systems either, they're half cheating

I should look into Fencing, or Kendo.

 
awsomdino:

Igor, we're talking about code here)

and i don't like his systems either, they're cheating.

I'm actually reading a book here))) ("Programming Without Fools")

i don't know his systems, but i use codes from QB - he's a real time saver, i'll even say - he created a robust infrastructure that i can take and use, the more so he maintains his codes constantly

 
awsomdino:

Classes, inheritance, virtualisation, templates, it was very difficult for me to understand this as a self-taught person, I understood a little and abandoned OOP, I can't even imagine how people bother in their robots - that they need to use all this, it's just a show-off. Structures at most.

Semka went away with his drawing, who needs this drawing, here they came to earn money for themselves and their loved ones, of course the developers didn't feel sorry for him. Peter, anything but trade). The programmers are baffled by their unnecessary functionality.

#define  LOG(dText) CLog::Get().Log((string)__LINE__,__FUNCSIG__,dText)

class CLog{
   CLog() {}
public:
   static CLog* Get() {static CLog _log; return &_log;}
   void Log(string line,string sig,string text) {PrintFormat("Line: %s. Signature: %s. %s",line,sig,text);}
};
//+------------------------------------------------------------------+
void OnStart()
{
   LOG("Example 1");
   Test();
}
//+------------------------------------------------------------------+
void Test(){
   string t="Example 2";
   LOG(t);
}

Here you have OOP and macrosubstitution and even a dodgy loner (for those who appreciate speed). This was written as an example, but naturally, you can create a file for logging in the constructor, write into it in Log(...) and close it in the destructor. This is an example of what all this is about. Of course, you can work out on functions, but in case of your own file, you'll have more code, and you'll get global variables, and it's not very orthodox))))

 
Vladimir Simakov:

Here you have OOP and macro substitution and even a simple singleton (this is for speed lovers). It's written for example, but naturally, you can create a file for logging in the constructor, write to it in Log(...), and close it in the destructor. This is an example of what all this is about. Of course, you can work with functions, but in the case of your own file, you'll have more code, and you'll get more global variables, and it's not very orthodox))))

Thank you, I will save the example

 
awsomdino:

Thanks, I'll save the example.

The funny thing is, you don't need to save it, you need to understand it. A person who understands will immediately write that a loner isn't needed here, and everything can be reduced to

#define  LOG(dText) CLog::Log((string)__LINE__,__FUNCSIG__,dText)

class CLog{
public:
   static void Log(string line,string sig,string text) {PrintFormat("Line: %s. Signature: %s. %s",line,sig,text);}
};
//+------------------------------------------------------------------+
void OnStart()
{
   LOG("Example 1");
   Test();
}
//+------------------------------------------------------------------+
void Test(){
   string t="Example 2";
   LOG(t);
}
 
Vladimir Simakov:

The funny thing is that you don't need to save it, you need to understand it. An understanding person will write at once that the loner isn't needed here, and everything can be reduced to

thank you, it's a code I've understood for a long time)

by the way, write the code better in default format, it's on such nuances I got stuck

_Symbol
Symbol();

symbolinfo and other one-note things that really screwed up my attention and time.

what can i say, i still dont have 100% information and have questions about what to use out of it.

 
Vladimir Simakov:

The funny thing is that you don't need to save it, you need to understand it. Anyone who understands will write that we don't need the singleton here, and everything can be reduced to

a misunderstood one will write that we don't need OOP here, we can replace it by a function call

and then again fall into two camps and get into a mess for several pages )))

 
Igor Makanu:

an understanding person will write that OOP is unnecessary here, you can replace it with a function call

and then again into two camps and a mess for several pages)))

Well done! That's right! And this?

#define  LOG(dText) CLog::Ptr().Log((string)__LINE__,__FUNCSIG__,dText)

class CLog{
   int cHndl;
   CLog():cHndl(FileOpen(MQLInfoString(MQL_PROGRAM_NAME)+_Symbol+(string)(int)TimeCurrent()+".log",FILE_TXT|FILE_WRITE)){}
  ~CLog() {FileClose(cHndl);}
public:
   static CLog* Ptr() {static CLog _log; return &_log;}
   void Log(string line,string sig,string text){
      string _text=StringFormat("Line: %s. Signature: %s. %s",line,sig,text);
      PrintFormat(_text);
      FileWrite(cHndl,_text);}
};

You'll agree that it's more complicated)))

 
Vladimir Simakov:

Well done! That's right! And this?

You have to admit it's a bit more complicated)))

Where there's classes, there's buggies all over)

* and & may surprise you

Not complicated code, the only convenient class, constructor with a destructor, I don't see any other pluses yet,

structures are more convenient and less complicated to learn.)

Many don't even know or don't understand the capabilities of structures. It was not long ago that Tumblr publicly began to widely use in his code.