Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1045

 
Alexandr Sokolov:

I still get non-normalized values after normalization - MQL5

Most unfavourable 1e-05, What to do?

DoubleToString(....) will help you.

 

There is some trick to getting the value of an element from a higher class


Code:

class B
  {
   int x
   int               GetA()
     { ????  }
  };

class A
  {
   int               a;
   B                 b;
public:
  };


An element of class B is inside class A. How can I get the value of a (from class A) from within B?

 
Sergey Likho:

Is there any trick to getting the value of an element from a higher class


Code:


An element of class B is inside class A. How can you get the value of a (from class A) while inside B?

Class B knows nothing about Class A.
You need to inherit. Then you can call the parent class method from the child class. Better using context resolution operator ::
 
Sergey Likho:

Is there any trick to getting the value of an element from a higher class


Code:


An element of class B is inside class A. How can I get the value of a (from class A) from within B?

class A;

class B
  {
   A*  ptr;
   int x;
public:
   B(int mX,A* mPtr):ptr(mPtr),x(mX){}
   void  Print() {Alert("From B\na=",ptr.Get(),"\nx=",x);}
  };

class A
  {
   int               a;
   B*                b;
public:
   A(int mA,int mB):a(mA),b(new B(mB,&this)){}
  ~A() {delete b;}
   void   PrintB() {b.Print();}
   void   PrintA() {Alert("From A\na=",a);}
   int    Get()   {return a;}
  };
  
void OnStart(){
   A a(8,10);
   a.PrintA();
   a.PrintB();   
  }
 
Artyom Trishkin:

Please advise:

Can you tell me how to solve the problem withcalling the indicator on MT5 windows 10 X64, I am doing this way:

#resource "\\Indicators\\\MyIndicator.ex5"

handle=iCustom(NULL,0,"::Indicators\\\\MyIndicator");

It used to work without #resource, then it only started working with #resource, now nothing works, error 4804 is generated

Способы вызова индикаторов в MQL5
Способы вызова индикаторов в MQL5
  • www.mql5.com
В MQL5 существует несколько вариантов вызова индикаторов, и осуществляются они в основном при помощи функций IndicatorCreate() и iCustom(). Причем эти функции лишь возвращают хендл индикатора, и дальнейшая работа с индикаторами ведется именно через него. Так что же такое хендл? Как работать с функциями IndicatorCreate() и iCustom()? И как...
 
Alexandr Sokolov :

I still get non-normalized values after normalization - MQL5

Most unfavourable 1e-05, What to do?

Try this:


if (index <= 65 && index> = 55 ) PrintFormat (index, "" , up, "" , down, "" , sum, "%.5f" , minus);
 
Sergey Likho:

There is some trick to getting the value of an element from a higher class


Code:


An element of class B is inside class A. How can I get the value of a (from class A) inside of B?

class A;

class B
{
public:
   int x;
   int               GetA(A &reference) {  return reference.a;} };
//+------------------------------------------------------------------+
class A
{
public:
   int               a;
   B                 b; };
//+------------------------------------------------------------------+
A obj;
void OnStart()
{
   obj.a = 10;
   int result = obj.b.GetA(obj);
   printf("result = %d",result);
}
//+------------------------------------------------------------------+

2020.01.20 20:30:05.534 tst (EURUSD,H1) result = 10

 
Igor Makanu:

2020.01.20 20:30:05.534 tst (EURUSD,H1) result = 10

Wrong. You pass a pointer to an object in a method. My point is as follows:

class A;

class B
  {
   A*  ptr;
   int x;
public:
   B(int mX,A* mPtr):ptr(mPtr),x(mX){}
   void  Print() {Alert("From B\na=",ptr.Get(),"\nx=",x);}
  };

class A
  {
   int               a;
   B                 b;
public:
   A(int mA,int mB):a(mA),b(mB,&this){}
   void   PrintB() {b.Print();}
   void   PrintA() {Alert("From A\na=",a);}
   int    Get()   {return a;}
   B*     GetB() {return &b;}
  };

void OnStart(){
   A a(8,10);
   B* b=a.GetB();
   b.Print();   
  }
That is, you can get a pointer to B from A and work with it, while B has access to A
 
Vladimir Simakov:

Wrong. You pass a pointer to an object in a method. My point is this:

That is, you may take a pointer to B from A and work with it, and B has access to A

I've seen your code

But this isn't the first time the questioner "handles a fig leaf" in no uncertain terms - I already answered this question nearly on OOP once ))))

he basically just needed a description of class A forward, but he's the only one who knows)))


HH: I'm passing a reference to an object; you can do whatever you want by that reference, but there's no sense in general in such code. Usually, as you've written in your example, you use a class pointer to yourself and then it's convenient to use it all

 
I've written a simple free indicator, but I can't add a description. I fill it out according to all the requirements, press "save" - everything is OK, no errors. But after the page loads, there is no description...
Reason: