Hi,
you will find hundreds of examples in the CodeBase section. (https://www.mql5.com/en/code)
It doesn't mention if it is for MQL4 or MQL5. Make sure of that when you do the search.
Here you have the complete documentation of the MQL5 language: https://www.mql5.com/en/docs
And here hundreds of articles: https://www.mql5.com/en/search#!keyword=datetime&module=mql5_module_articles
![MQL5 Code Base MQL5 Code Base](https://c.mql5.com/36/78/mql5-code-base__1.png)
As a beginner you might profit from reading this in advance:
1) HowTo Begin with MT5 instalation:
https://www.metatrader5.com/en/terminal/help/start_advanced/installation
https://www.mql5.com/en/forum/432663#comment_42071081
https://www.metatrader5.com/de/terminal/help
2) broker: https://www.mql5.com/en/forum/446683
3) MQL5:
If you place the cursor on an MQL function and press F1, you will see the reference directly, many with examples of copying and pasting the fastest form to code.
https://www.mql5.com/en/articles/496
https://www.mql5.com/en/articles/100
and for debugging: https://www.metatrader5.com/en/metaeditor/help/development/debug
https://www.mql5.com/en/search#!keyword=cookbook
"Bear in mind there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - so searching gives better results than AI or ChatGPT!" (Carl Schreiber):
=> Search in the articles: https://www.mql5.com/en/articles
=> Search in the codebase: https://www.mql5.com/en/code
=> Search in general: https://www.mql5.com/en/search or via Google with: "site:mql5.com .." (forgives misspelling)
4) indicators: see this series of articles:
https://www.mql5.com/en/users/m.aboud/publications
Each article explains an indicator (built into MT5) and what it tells you, and how you might use it in an EA.
- www.metatrader5.com
- You probably do not want 20 days ago, you probably want 20 trading days ago. Isolate the time of your datetime, and access n yesterdays ago.
Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017) -
You could also use D1 timeframe, but then you have to deal with 4066 / synchronization issue.
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use