1

OrderSelect(,,MODE_HISTORY)

In a live metatrader account, does it store all closed positions from the first time i opened an account with a broker?

I wanted to make an expert advisor that calculates my winrate on a certain pair. I need to find out the data limit mt4 handles. Can I go say, 100 trades back? Will that still be available or would that have been deleted by mt4? If so, how about 500 trades? 1000? What is the limit? Is there any?

I guess an answer to this question will also reveal the maximum possible integer output for OrdersTotal, if there is any.

2 Answers2

0

Go to terminal window -> Account History -> Right-Mouse Click -> Select all history. You can read all the history that is shown using OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) but if you do not have that history (e.g., you chosen last months and on 31th January it shows all January, next day it shows only February) then it will not return past trades.

Daniel Kniaz
  • 4,603
  • 2
  • 14
  • 20
  • Im not asking how to reveal the trade history. What im asking is how much historical trades is stored in mt4. How far back can you go with OrderSelect(,,MODE_HISTORY)? I noticed that my account only goes back one month even if I have "All History" shown. All trades before that is gone. Cannot be accessed. I guess im also asking how to change that. – Robert Simon Uy Jan 15 '18 at 23:56
  • if you have history in your Account history tab, you can catch it all by OrderSelect(). Documentation does not tell about any restrictions on that – Daniel Kniaz Jan 17 '18 at 11:19
  • Then why is it that my history only goes back one month, even after having the "All history" button clicked? Maybe when I had it unclicked it only stored data of one month. Or maybe i deleted it somewhere on my computer? Or is it stored on a server or something? Btw, im virtually hosted, so Im not sure if that also has an impact. – Robert Simon Uy Jan 18 '18 at 02:48
  • Cannot tell you about how it is hosted, it is possible that on server. Make sure you selected all history and you can see all history not just last month. If you can see that history with your eyes - then you would be able to loop over it – Daniel Kniaz Jan 18 '18 at 10:53
0

It depends on your broker (i.e., its trading server settings). Normally, brokers choose to "compress" the past order data to store only last 1-3 months of history.

Enivid
  • 210
  • 2
  • 9