Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+------------------------------------------------------------------+
- //| Test2.mq5 |
- //| Copyright 2025, MetaQuotes Ltd. |
- //| https://www.mql5.com |
- //| Scrie in C:\Program Files\MetaTrader 5\MQL5\Files\bidask.csv |
- //| si consola |
- //+------------------------------------------------------------------+
- #property copyright "Copyright 2025, MetaQuotes Ltd."
- #property link "https://www.mql5.com"
- #property version "1.00"
- int filehandle;
- //+------------------------------------------------------------------+
- //| Expert initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- ResetLastError();
- filehandle=FileOpen("bidask.csv",FILE_WRITE|FILE_CSV);
- if(filehandle!=INVALID_HANDLE)
- {
- Print("File opened correctly");
- }
- else Print("Error in opening file,",GetLastError());
- return(INIT_SUCCEEDED);
- }
- //+------------------------------------------------------------------+
- //| Expert deinitialization function |
- //+------------------------------------------------------------------+
- void OnDeinit(const int reason)
- {
- //---
- FileClose(filehandle);
- }
- //+------------------------------------------------------------------+
- //| Expert tick function |
- //+------------------------------------------------------------------+
- void OnTick()
- {
- //---
- MqlTick last_tick;
- if(SymbolInfoTick(Symbol(),last_tick))
- {
- Print(last_tick.time,": Bid = ",last_tick.bid,
- " Ask = ",last_tick.ask," Volume = ",last_tick.volume);
- FileWrite(filehandle,last_tick.bid,last_tick.ask);
- }
- else Print("SymbolInfoTick() failed, error = ",GetLastError());
- }
- //+------------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement