Questions from Beginners MQL5 MT5 MetaTrader 5 - page 766

 
Aleksey Vyazmikin:

I propose not to deviate from the concept, which, as I understood it, was to copy a certain amount of bar data at the beginning of the code, and then work with this data - or are you suggesting an exception?

And, what makes you think I'm a programmer?

I don't think it's necessary to guess - what will be faster, sometimes the answer may not be obvious - only experience can give an answer to such questions.

Then you are welcome here.

 
Vitaly Muzichenko:

You need to delete objects with a Ticket which are already in the history, but not those which are still in the market.

You need a Ticket for a closed position, but you can't get it with PositionSelect().

 
Vitaly Muzichenko:

you need to delete objects with a ticket that are already in the history, but not those that are still in the market

Duplicate:

What if the task is "reversed"?

Remove ticket objects whose positions are already out of the market... or do NOT remove ticket objects, which are not yet in the history, and remove the rest... Which is basically the same thing.

 
Ivan Ivanov:

In short, you need Ticket of already closed position, but you can't get it with PositionSelect().

Here is a script, which returns Ticket of all closed Positions in history period.

void OnStart()
{ ulong DealTicket; // for Function : replace void with ulong
  ulong PositionTicket;
  if ( HistorySelect(TimeCurrent()-30*24*60*60,TimeCurrent()) ) // Select History = 30 days
  { if ( HistoryDealsTotal()>0 )
    { int DealIndex=HistoryDealsTotal()-1;
      while ( DealIndex>=0 )
      { DealTicket=HistoryDealGetTicket(DealIndex); // select Deal 
        if ( HistoryDealGetInteger(DealTicket,DEAL_ENTRY)==DEAL_ENTRY_OUT ) // Deal close Position
        { PositionTicket=HistoryDealGetInteger(DealTicket,DEAL_POSITION_ID);
          Print("\n DealTicket = "+IntegerToString(DealTicket));
          Print("PositionClosedByDeal = "+IntegerToString(PositionTicket));
          // if ( some condition ) // for Function : Your selection
          // return (PositionTicket); // for Function : Enable return
        }
        DealIndex--;
      }
      // Print("Warning = Nothing selected from History"); // for Function : remove //
    }
    else Print("Warning = Empty History (select longer History)");
  }
  else Print("Error = "+IntegerToString(GetLastError())+" = Not loaded History");
  // return (-1); // for Function : Enable return
}

The code tells how to convert it to a function (in English)

 
Ivan Ivanov:

Here is the script which returns the Ticket of all closed Positions for a given History period.

The code shows how to convert it to a function (in English)

The most interesting thing is that it was already mentioned right away:

Forum on Trading, Automated Trading Systems and Strategy Testing

Questions from Beginners MQL5 MT5 MetaTrader 5

Artyom Trishkin, 2017.07.24 23:33

Have you tried looking for a closed trade (OUT)? The order was there - you can see it.

But Vitaly did not understand the meaning of what was written. And he did not even ask me to repeat it.
 
Artyom Trishkin:

The interesting thing is that this was already mentioned right away:

But Vitaly apparently did not grasp the meaning of written. And he didn't even ask me to repeat it.

Thanks Artyom, I decided to leave that for later, I asked while I was sleeping)


Ivan Ivanov:

Here's the script that returns the Ticket of all closed Positions for a given History period.

The code tells how to convert it into a function (in English)

Thanks for the code, it helped.


Problem solved!

 
Artyom Trishkin:

The interesting thing is that this has already been mentioned right off the bat:

But Vitaly didn't seem to grasp the meaning of what was written. And he didn't even ask again.

To the moderator:

The man wanted the code (implementation idea). And there was NOT, but he was sent to Freelance.

 
Ivan Ivanov:

To the moderator :

The person wants the code (implementation idea). And there it was NOT beaten, but sent to freelance.

Does the moderator have a name?
I know Vitaly. It is enough for him to show the right direction. Code is for lazybones and dumbasses. And it was not Vitaly who was sent to freelancing. But someone who is not a programmer.
An implementation idea is an idea, an algorithm.
And the implementation is code, and not always the right one.

 
Artyom Trishkin:
Does the moderator have a name?
I know Vitaly. It's enough for him to show the right direction. Code is for lazybones and dumbasses. And it wasn't Vitaly who was sent to freelance. But to someone who is not a programmer.
The idea of implementation is an idea, an algorithm.
And the implementation is code, and not always the right one.

Does someone who is not a programmer have a name?

Yes, I am not a programmer by education, but every day I work on mastering this not easy skill.

 
Aleksey Vyazmikin:

Does someone who is not a programmer have a name?

Yes, I'm not a programmer by training, but I work every day to master this not easy skill.

Ah, there you go. Still have the desire to learn programming? Then try to understand what is offered and do not make yourself as an examiner. No offense, but that's how I understood all objections and questions about CopyRates().

I'm not a programmer by education either. When I studied there was no such a specialty and counted on an arithmometer "Felix".