Initial commit: MQL5 Scripts Collection (MetaTrader 5)

This commit is contained in:
GeneralTradingSarl
2025-06-24 00:33:04 +01:00
commit 60a549d89c
1959 changed files with 31907 additions and 0 deletions
@@ -0,0 +1,22 @@
# 🚀 Unlock the Power of Trading!
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
---
**Support the project:**
- Star this repository on GitHub
- Share it with your trading friends
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
---
![Screenshot](library.png)
![Screenshot](max_bars_on_chart__1.jpg)
![Screenshot](request_historical_data__1.jpg)
![Screenshot](script.png)
## Source Files
- `script_ohlcv_to_csv.mq5`
---
> Made with ❤️ for the trading community.
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

@@ -0,0 +1,90 @@
//+------------------------------------------------------------------+
//| Script_OHLCV_CSV.mq5 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link "shmtrading3000@gmail.com"
#property version "1.01"
#property description "This script saves the available OHLCV data from the chart to a CSV file inside '<User>\\AppData\\Roaming\\MetaQuotes\\Terminal\\Common\\Files'.\nMake sure 'Max bars in chart' is set to unlimited in 'Tools>Options>Chart'."
#property script_show_inputs
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
int digits = Digits();
double tick_size = SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_SIZE);
int bars = iBars(Symbol(), PERIOD_CURRENT);
string output_file_name = (string) Symbol() +
"-" +
(string) Period() +
"-" +
TimeToString(iTime(Symbol(), PERIOD_CURRENT, bars - 1), TIME_DATE) +
"-" +
TimeToString(iTime(Symbol(), PERIOD_CURRENT, 0), TIME_DATE) +
".csv";
ResetLastError();
int handle_write = FileOpen(output_file_name, FILE_WRITE | FILE_BIN | FILE_COMMON);
if(handle_write == INVALID_HANDLE)
{
int error = GetLastError();
Print("Error " + (string) error + ", Failed to write the results to csv.");
return;
}
//--- Write the header row to csv
FileWriteString(handle_write, "<DATE>" + ",");
FileWriteString(handle_write, "<TIME>" + ",");
FileWriteString(handle_write, "<OPEN>" + ",");
FileWriteString(handle_write, "<High>" + ",");
FileWriteString(handle_write, "<LOW>" + ",");
FileWriteString(handle_write, "<CLOSE>" + ",");
FileWriteString(handle_write, "<TICKVOLUME>" + ",");
FileWriteString(handle_write, "<VOL>" + ",");
FileWriteString(handle_write, "<SPREAD>");
FileWriteString(handle_write, "\r\n");
for(int i = bars - 1; i >= 0; i--)
{
//--- Get the data for the current bar
datetime _time = iTime(Symbol(), PERIOD_CURRENT, i);
string date = TimeToString(_time, TIME_DATE);
string time = TimeToString(_time, TIME_MINUTES);
string open = PriceToString(iOpen(Symbol(), PERIOD_CURRENT, i), tick_size, digits);
string high = PriceToString(iHigh(Symbol(), PERIOD_CURRENT, i), tick_size, digits);
string low = PriceToString(iLow(Symbol(), PERIOD_CURRENT, i), tick_size, digits);
string close = PriceToString(iClose(Symbol(), PERIOD_CURRENT, i), tick_size, digits);
string tick_volume = (string) iTickVolume(Symbol(), PERIOD_CURRENT, i);
string volume = (string) iVolume(Symbol(), PERIOD_CURRENT, i);
string spread = (string) iSpread(Symbol(), PERIOD_CURRENT, i);
//--- Write the data to csv
FileWriteString(handle_write, date + ",");
FileWriteString(handle_write, time + ",");
FileWriteString(handle_write, open + ",");
FileWriteString(handle_write, high + ",");
FileWriteString(handle_write, low + ",");
FileWriteString(handle_write, close + ",");
FileWriteString(handle_write, tick_volume + ",");
FileWriteString(handle_write, volume + ",");
FileWriteString(handle_write, spread);
FileWriteString(handle_write, "\r\n");
}
FileClose(handle_write);
Alert("Saved the price data successfully. Find the file in '<User>\\AppData\\Roaming\\MetaQuotes\\Terminal\\Common\\Files\\" + output_file_name + "'");
}
//+------------------------------------------------------------------+
string PriceToString(double price, double tick_size, int digits)
{
double price_norm = NormalizeDouble((price / tick_size) * tick_size, digits);
return DoubleToString(price_norm, digits);
}
//+------------------------------------------------------------------+