Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2016.03.25 13:57
Writing the quotes to a txt file with the full path and file name

Writing the quotes to a txt file with the full path and file name - library for MetaTrader 4

| English Español Русский 中文 Deutsch 日本語 Português

Views:
540
Rating:
votes: 6
ITTPSymbol.dll (384 KB)

Function Description:

#import "ITTPSymbol.dll"  
    int CreateFile(string Path, string symbol, int Priсe);

An example of a function call:

 CreateFile(Path, Symbol(), Ask);

As you can see, everything is very simple. The function will create a text file with the name 'symbol' and write(overwrite) the 'Price' value there. According to the path specified in the value of Patch. This library was written in Delphi. If anyone is interested, they can redo it.

The source code of the library in Delphi:

library ITTPSymbol;
 
 uses classes, Dialogs,sysutils;



{$r *.res}
function CreateFile(Path: Pchar ;  Symbol: Pchar;  Priсe: integer ): integer; stdcall;
 
var outfile: TextFile;
 
begin
AssignFile(outfile, string(Path)+'\' + string(Symbol) + '.txt');
 
 try
   Rewrite(outfile);
   writeln(outfile, Priсe);
   CloseFile(outfile);
   Result:=0;
 except
   Result:=1;
 end;
   Result:=0;
 
end;
 
exports CreateFile;
 
end.

if the function ran successfully the CreateFile() function returns 0, otherwise -1.


Sample script that writes a file with the name of the current symbol the script was run on to the C:\ drive. At the same time the 'Price' parameter of 'integer' type is written to the file:

//+------------------------------------------------------------------+
//|                                                   ITTPSymbol.mq4 |
//|                                        Copyright © 2007 ITTP Gr. |
//|                                         http://www.ITTPortal.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007 ITTP Gr."
#property link      "http://www.ITTPortal.net"
//---- 
#import "ITTPSymbol.dll"  
    int CreateFile(string Path, string symbol, int Price);
string Path;
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
      Path = "C:"; // The last slash "\" is not specified! 
   CreateFile(Path, Symbol(), 53); 
//----
   return(0);
  }
//+-------

That is it, use at will.

16.04.2007. Fixed several errors in the new version of the dll:

  • replaced Patch with Path;
  • removed the unnecessary code from the library itself.

The old version of the library is deleted, so that it can be downloaded safely.

Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/7084

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

LinesProfitLoss LinesProfitLoss

Calculates profit (loss) of the current orders on the symbol.

FFC - Forex Factory Calendar FFC - Forex Factory Calendar

Modified version of FF Calendar Indicator with new features.