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

 
Vladimir Pastushak:

Thank you. I'm having trouble calling a parent class method.

As far as I remember it is done via parent :: method

Does the method itself have a body in the parent?

 
Artyom Trishkin:

Does the method itself in the parent have a body?

Yes, it does.

Here's the code, what am I doing wrong ?

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

class A

  {

public:

   virtual int Test_A()

     {

      return 100;

     }

  };

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

class B :public A

  {

public:

   virtual int Test_A()

     {

      return 200;

     }

  };


B b;

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

void OnStart()

  {

   Comment (A::b.Test_A());

  }

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


 
There is a zigzag indicator that shows the price value of an extremum, I need to drawa trend line from the extremum to the future (the next day), how can I do that without knowing the coordinates of the second point and the Time value of the first point?
 
Vladimir Pastushak:

Here's the code, what am I doing wrong ?

no, it won't work that way

by writing the test() body in the B class, you've closed the old Test() function and now when you declare an instance of the class and call the Test() method, it will always run B::Test(), but if you didn't write B::Test(), it would always run A::Test()

here's an example. experiment with it

//+------------------------------------------------------------------+
class A
  {
public:
   virtual int Test_A()  { Print(__FUNCSIG__); return 100;  }
  };

//+------------------------------------------------------------------+
class B :public A
  {
public:
   virtual int Test_A()  { Print(__FUNCSIG__," = ", A::Test_A()); return 200;   }
  };

B b;

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

void OnStart()

  {
   Print (__FUNCSIG__," = ",b.Test_A());
  }
//+-------------------------------------------------------------
 
Hi. How do I do an ordinal calculation? So that in place of SELL first there will be 1, then 2 and so on... ...until it refreshes when there are no orders. Some hints!
        if((fMarketOrderss(OP_SELL)>=1)) { 
       if( ((Bid-Opens)/ma+Times/1440) > SELL ) {
if(OrderSend(Symbol(),OP_SELL,0.01,Bid,3,0,0,NULL,321,0,1)>0){} }}
 
Hmm, strange, no one is answering.
 
Rustam Bikbulatov:
Hmm, strange, no one replies.

I don't think anyone understands your post :)


 

Hi, how to make the EA open positions with a specified volume of single orders of both positions according to external variables, e.g.

The volume of a single order is 1.35 lots, the total volume of the open positions is 500 lots. The EA opens a buy order of 1.35 lots, and then opens a sell order of 1.35 lots,

and then repeats until 500 lots buy and 500 lots sell are opened, and since the number of lots is not a multiple of 1.35, the last order must be less than 1.35

 

Greetings.

I made a function that when an order reaches profit points "bezubitok", it modifies the order by moving it to the order opening level. It seems to work correctly, but during testing (and on all ticks) every 10-20th time it sends error 1 to the log.

No error, but the result is unknown

void Bezubitok(){
   for (int i=OrdersTotal()-1; i>=0; i--){
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic){
            if(OrderType()==OP_BUY){
               if (OrderStopLoss()!=OrderOpenPrice() && Ask-OrderOpenPrice()>bezubitok*Point){
                  double sl1 = OrderOpenPrice();
                  if(OrderModify(OrderTicket(), OrderOpenPrice(), sl1, OrderTakeProfit(), 0, Indigo)) {}
                  }
               }
            if(OrderType()==OP_SELL){
               if (OrderStopLoss()!=OrderOpenPrice() && OrderOpenPrice()-Bid>bezubitok*Point){
                  double sl1 = OrderOpenPrice();
                  if(OrderModify(OrderTicket(), OrderOpenPrice(), sl1, OrderTakeProfit(), 0, DeepPink)) {}
                  }
               }
            }   
         }
      }
   }

What is the reason for this and how do I defeat it?

 
Andrey Sokolov:

Greetings.

I made a function that when an order reaches profit points "bezubitok", it modifies the order by moving it to the order opening level. It seems to work correctly, but during testing (and on all ticks) every 10-20th time error 1 is written to log.

What is the reason for this and how do I fix it?

Error 1 is no error, but the result is unknown. The point is that you are trying to modify the stop to the same price it is already at. Before modifying it, compare the price of the stop with the price at which you want to set it. If it is already at that price, there is nothing to modify.