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

 
Artyom Trishkin visibility flags on timeframes. Need to hide and display.

I wrote to them about it a few days ago. But who ever listens to sound advice...?

 

Forum on trading, automated trading systems & strategy testing

Any questions from newbies on MQL4 and MQL5, tips and discussion on algorithms and codes

Mihail Matkovskij, 2021.12.03 22:27

You can hide an object from the chart and then show it. Or use CHARTEVENT_OBJECT_CLICK - it's perfect!


I don't think there's any need to comment further...? :)
 
Mihail Matkovskij #:
A more compact version:

I am not a programmer and do not know styles (I write as I can).

Mihail Matkovskij #:

But I thought you said your function pretends to be universal...? Then you forgot one very important detail:

const-don't know what it is, but it works wonderfully without it.


Mihail Matkovskij #:

Are you too lazy to write a simple script to check it? Ok. I did it for you:

Strange...

this function generates false on "-n".

I'm not a programmer or a teacher. I'm here to ask and answer (if I know). I don't do pissing matches.

If you want to show your worth, learn to admit mistakes or correct them.

 
Mihail Matkovskij #:

I wrote to them about it a few days ago. But who ever listens to sound advice...?

I too have noticed that the more active ones tend to be listened to. In this case Makar. As a result, the simplest problem has not been solved for several days.

 
Alexey Viktorov #:

I too have noticed that the more active ones are more often listened to. In this case Makar. As a result, for several days the simplest task has not been solved.

Alexei, the problem has long been solved, the man wanted to understand why this particular option does not work.
 
MakarFX #:


const - I don't know what it is, but it works fine without it.

const, it's a guarantee that the value won't change inside the function

Strange...

it's the function that gives out false

I think I've got it all straightened out. What's wrong?

I'm not a programmer and I'm not a teacher. I'm asking and answering (if I know). I am not trying to show off my pussy.

If you want to show your worth, you better learn to admit your mistakes or correct them.

I also answer questions. And I'm trying to convey what a well-written code should look like. And you're talking to me about my ego? I think you and Nerd Trader misunderstand me. I already said above that for me the importance of programming knowledge is what matters, not my importance!

In principle, no one is going to teach you apart from your will. But the code, which was written for you, but you don't like it, doesn't fit or you don't understand it, will probably be useful for other forum members. So if you don't like the code, don't use it. Use the one you like.

 
MakarFX #:
Alexei, the problem has long been solved, the man wanted to understand why this particular variant does not work.

Everything is working properly and they're messing with everyone's head here instead of comparing the right version to the wrong one. :)

 
законопослушный гражданин #:

clearly

Please, advise if I understand correctly that the function returns the lot of the last closed order but the accounting starts from the beginning of the list of all closed orders

double GetLotSize()
  {
   double Ls=0;
   datetime t=0;
   int i=OrdersHistoryTotal();
   for(int pos=0; pos<i; pos++)
     {
      if(OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY))
        {
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(t<OrderCloseTime()) {t=OrderCloseTime(); Ls=OrderLots();}
              }
           }
        }
     }
   return Ls;
  }

and if I do it that way, it will be counted from the end of the list?

double GetLotSize()
  {
   double Ls=0;
   datetime t=0;
   int i=OrdersHistoryTotal();
   for(int pos=0; pos>=i; pos--)
     {
      if(OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY))
        {
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(t<OrderCloseTime()) {t=OrderCloseTime(); Ls=OrderLots();}
              }
           }
        }
     }
   return Ls;
  }
 
законопослушный гражданин #:

Could you please tell me if I understand correctly that the function returns the lot of the last closed order but the accounting starts from the beginning of the list of all closed orders

so if I do it that way, it will be counted from the end of the list?

Yes
 
законопослушный гражданин #:

Could you please tell me if I understand correctly that the function returns the lot of the last closed order but the accounting starts from the beginning of the list of all closed orders

If I do it this way, the countdown will be done from the end of the list?

The second variant will not work. To do the count from the end of the list, we should do the following:

double GetLotSize()
  {
   double Ls=0;
   datetime t=0;
   int total = OrdersHistoryTotal();
   for(int i = total - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
        {
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(t<OrderCloseTime()) {t=OrderCloseTime(); Ls=OrderLots();}
              }
           }
        }
     }
   return Ls;
  }
Reason: