Interesting take on the PLO - page 3

 
Alexandr Andreev:

) can also be done in assembly language. The question is where it's easier.

And don't put me to one side or the other.... I'm not a stickler for one thing or the other.

No one is. I'm just saying that nowadays OP features are available in modern OOP languages, as well as OOP features in multi-paradigm languages. In addition, many features of FP, presented as something special and amazing, in fact, are the same eggs in profile. They have been around for a long time - like closures in Pascal or delayed execution of a function in C where a pointer is passed to it instead of the result. What in the example in the article is given in any language does not work almost anywhere except js (except maybe in Python yet).

 
fxsaber:

I'm not good at OOP. But I do use primitive things from it. From the recent past, I posted some very simple code.


Started writing it in FP, when I didn't understand what I'd end up looking at.

Finished through the primitive elements of OOP. Probably lost FP skills, but here OOP seemed much simpler and more readable.


The code is very simple and short(description). If you write it in FP, it would be interesting to compare.

The code is much smaller than that often posted here, you'd better display it here, it's good for educational purposes

I would like Dmitry Fedoseyev to write his version, and then Expert will troll him with his)
 
fxsaber:

I'm not good at OOP. But I do use primitive things from it. From the recent past, I've posted some very simple code.


Started writing it in FP, when I didn't understand what I'd end up looking at.

Finished through the primitive elements of OOP. Probably lost FP skills, but here OOP seemed much simpler and more readable.


The code is very simple and short(description). If you write it in FP, it would be interesting to compare.

I'll have a look at the calculator as soon as I get free. And you are a telepath, I was going to ask in another thread, but I'll ask here, by your experience of debugging in "real mode" - are there possible "holes" in T_OHLC_V data in MT4 and in MT5?

I.e. is it possible that after any slack (connection failure, the terminal hangs up, the system hangs up), the new data will be initially with some skip, and then the skip/"hole" will be written inside of the array? Of course, I will write my own detector for indicators and EAs, but maybe you already have experience of such testing and I don't have to worry about it.

And I have no experience of FP (or have, but did not know about the name), the automatic where to refer? ), I think I'm making do with the procedural paradigm.

zy. request request)

 
Aleksey Mavrin:

Strange article. OOP doesn't differ from procedural style for the worse, because in it you can do everything in procedural style by default, and vice versa without terrible code bloat, i.e. OOP is a "superstructure over", not a fundamentally different style.

If the article is really about functional rather than procedural (which isn't that obvious if you pick on it), then why compare things that have completely different uses.

Topeka starter, are you yourself writing and now talking about which one? functional or procedural?

With the advent of OOP it really scared me off with encapsulations and inheritance and other morphisms that are popular to start an introduction to OOP with. They would write simply that data together with functions in one block - a class. But then I got used to this fashion - to invent new terminology every time. When I need OOP - no problem, but since it, in my humble opinion, is twice as voracious and slower than the procedural variant, I do with the procedural one at most.

And the question arose, because I wanted to hear opinions about FP and other variants, besides OOP and procedural, maybe someone has a super positive experience. And I guess it's wise to use some stable mix in functioning and not to be a fanatic.

 
Peter, re-link your name.
 
Fast235:

The code is much smaller than the ones often posted here, you'd better deploy it here, for educational purposes.

Piece of cake.

#property strict
#property script_show_inputs

input double inPerformance = 100; // Сколько процентов дает система за период
input double inGift = 50;         // Награда управляющего в процентах (< 100)
input int inN = 12;               // Сколько расчетных периодов

struct BASE
{
  double Investor;
  double Manager;
  double Summary;

  // Если управляющий снимает деньги в конце каждого расчетного периода.
  void Set1( const double Performance, const double Gift, const int N )
  {
    this.Investor = ::MathPow(1 + (Performance - 1)* (1 - Gift), N);
    this.Manager = (this.Investor - 1) * Gift / (1 - Gift);
    this.Summary = this.Investor + this.Manager;

    return;
  }

  // Если ничего не делалось в расчетные периоды.
  void Set2( const double Performance, const double Gift, const int N )
  {
    this.Summary = ::MathPow(Performance, N);
    this.Manager = (this.Summary - 1) * Gift;
    this.Investor = this.Summary - this.Manager;

    return;
  }

  // Если управляющий снимает деньги в конце каждого расчетного периода и реинвестирует их.
  void Set3( const double Performance, const double Gift, const int N )
  {
    this.Summary = ::MathPow(Performance, N);
    this.Investor = ::MathPow(1 + (Performance - 1)* (1 - Gift), N);
    this.Manager = this.Summary - this.Investor;

    return;
  }

  void operator *=( const double Deposit = 1 )
  {
    this.Investor *= Deposit;
    this.Manager *= Deposit;
    this.Summary *= Deposit;

    return;
  }
#define  TOSTRING(A) #A + " = " + ::DoubleToString(A, 4) + " "
  string ToString( const bool FlagName = true ) const
  {
    return(FlagName ? TOSTRING(Investor) + TOSTRING(Manager) + TOSTRING(Summary)
                    : ::StringFormat("||%-12.4f||%-12.4f||%-12.4f||", this.Investor, this.Manager, this.Summary));
  }
#undef  TOSTRING

};

struct PAMM
{
  double Performance; // Доходность за расчетный период
  double Gift;        // Вознагражение управляющего.
  int N;              // Сколько расчетных периодов.

  BASE Base1; // Если управляющий снимает деньги в конце каждого расчетного периода.
  BASE Base2; // Если ничего не делалось в расчетные периоды.
  BASE Base3; // Если управляющий снимает деньги в конце каждого расчетного периода и реинвестирует их.

  void Set( const double dPerformance, const double dGift, const int iN )
  {
    this.Performance = dPerformance;
    this.Gift = dGift;
    this.N = iN;

    this.Base1.Set1(1 + this.Performance / 100, this.Gift / 100, this.N);
    this.Base2.Set2(1 + this.Performance / 100, this.Gift / 100, this.N);
    this.Base3.Set3(1 + this.Performance / 100, this.Gift / 100, this.N);
  }

  void operator *=( const double Deposit = 1 )
  {
    this.Base1 *= Deposit;
    this.Base2 *= Deposit;
    this.Base3 *= Deposit;

    return;
  }

  string GetDescription( void ) const
  {
    return("Доходность за расчетный период " + ::DoubleToString(this.Performance, 1) + "%\n" +
           "Вознагражение управляющего " + ::DoubleToString(this.Gift, 1) + "%\n" +
           "Количество расчетных периодов. " + (string)this.N);
  }

  string ToString( const bool FlagName = true, const bool FlagDescription = true ) const
  {
    return(FlagDescription ? "Данные для инвестиционного счета со следующими характеристиками:\n\n" + this.GetDescription() +
                             "\n\nКонечный результат для Инвестора, Управляющего и Суммарно:"
                             "\n\nЕсли управляющий снимает деньги в конце каждого расчетного периода (1).\n" + this.Base1.ToString(FlagName) +
                             "\n\nЕсли ничего не делалось в расчетные периоды (2).\n" + this.Base2.ToString(FlagName) +
                             "\n\nЕсли управляющий снимает деньги в конце каждого расчетного периода и реинвестирует их (3).\n" + this.Base3.ToString(FlagName)
                           : this.Base1.ToString(FlagName) + this.Base2.ToString(FlagName) + this.Base3.ToString(FlagName));
  }
};

void OnStart()
{
  PAMM Pamm;

  Pamm.Set(inPerformance, inGift, inN);

  Print(Pamm.ToString());

  string Str = Pamm.GetDescription() + "\n   ";

  for (int i = 1; i <= 3; i++ )
    Str += ::StringFormat("||%-12s||%-12s||%-12s||", "Investor" + (string)i, "Manager" + (string)i, "Summary" + (string)i);

  for (int i = 1; i <= inN; i++ )
  {
    Pamm.Set(inPerformance, inGift, i);

    Str += StringFormat("\n%-2d:", i) + Pamm.ToString(false, false);
  }

  Print(Str);
}

Technically, it's probably an OOP. But it is its most primitive part. However, I couldn't do it without it. Probably, dumb brain rearrangement and riveting such things.

 

Peter ahahahah stop it.

My approach, the bucket is a pot

Мой подход. Ядро - Движок.
Мой подход. Ядро - Движок.
  • 2018.12.05
  • www.mql5.com
В этой ветке, я хочу рассказать о своем подходе в программировании. Заранее предупреждаю, - здесь не будет обсуждений GUI...
 
Maxim Dmitrievsky:

Peter ahahahah stop it.

My approach, the bucket is a pot

it's been a while since I've seen him...

Did he really go under a different screen name?

 
Maxim Kuznetsov:

I haven't seen him in a while...

did he really go under a different screen name?

rumor has it he's gone to build a strong AI

 
Maxim Dmitrievsky:

rumour has it that he has gone to create a strong AI

Just don't let anything happen, or COVID won't sleep...
Reason: