Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1547

 
Aleksandr Slavskii #:

Didn't notice the conversation was about the script.

If it's a script, then it is:

Don't forget to allow dll in the settings

Thanks a lot! I'll give it a try and let you know the results later.

 
klycko #:

Thank you very much! I'll give it a try and let you know the results later.

Good afternoon, Alexander!

I created the below script from your text and ran it.

I added lines to your text for control:

bool PrDelete = DeleteFileW(Path + ShortArrayToString(FindData.cFileName));

Print ("PrDelete=",PrDelete);


I have 3 files in the cache.

The script did not delete them and generated false twice.


Maybe it is because operations outside the sandbox are prohibited in MQL5?


By the way, line 31 looks unfinished.

#import


Regards, Alexander

//+------------------------------------------------------------------+

//| Delirium.mq5 |

//+------------------------------------------------------------------+

#property strict

#property script_show_inputs

#define MAX_PATH 260

struct FILETIME

{

uint dwLowDateTime;

uint dwHighDateTime;

};

struct FIND_DATAW

{

uint dwFileAttributes;

FILETIME ftCreationTime;

FILETIME ftLastAccessTime;

FILETIME ftLastWriteTime;

uint nFileSizeHigh;

uint nFileSizeLow;

uint dwReserved0;

uint dwReserved1;

short cFileName[MAX_PATH];

short cAlternateFileName[14];

};


#import "kernel32.dll"

int DeleteFileW(const string file_name);

long FindFirstFileW(const string file_name, FIND_DATAW &find_file_data);

int FindNextFileW(long find_file, FIND_DATAW &find_file_data);

int FindClose(long find_file);

#import

//+------------------------------------------------------------------+

void OnStart()

{

DeleteFile(TerminalInfoString(TERMINAL_DATA_PATH) + "\\Tester\\\cache");

}

//+------------------------------------------------------------------+

void DeleteFile(string Path)

{

FIND_DATAW FindData;

FindData.cFileName[0] = 0;

const long handle = FindFirstFileW(Path + "*.*", FindData);

if(handle != INVALID_HANDLE)

{

do

{

bool PrDelete = DeleteFileW(Path + ShortArrayToString(FindData.cFileName));

Print ("PrDelete=",PrDelete);

}

while(FindNextFileW(handle, FindData));

FindClose(handle);

}

}

//+------------------------------------------------------------------+
 
klycko #:

Good afternoon, Alexander!

Shit. I apologise. I was in a hurry. You need to add two slashes at the end of the line, like this:

"\\Tester\\cache\\"
 

Alexander, thank you very much!

Everything worked.

You have solved my big problem.

 
Vladimir Karputov #:

Interesting question. To understand it better I manually opened a position and specified the comment'123456' - then closed the position and ran the script History Deals and Orders. And now notice that the comment is present only for the order (trade order) on the basis of which the transaction that led to the position and the transaction that occurred as a result of the order execution occurred):


So when closing a position (in OnTradeTransaction transaction type TRADE_TRANSACTION_DEAL_ADD) it is necessary to select from the trading history all orders related to this position and search for the root cause order - thanks to which this position appeared.

This is because there was no order-transaction changing the comment. And if there had been such an order, there would have been a comment there. It turns out that it is necessary to check all deals on the position and search for a non-zero comment starting from the last deal belonging to the position.

 

Hello, can anyone tell me

where are traded in which DCs "unpopular currencies" such as:

HKD, AED, KWD, SAR, PLN, DKK, RON and others ?

can be sent in a private message

 
You open a market overview on the demo and see
 
Roman Kutemov #:

Hello, can anyone tell me

where "unpopular currencies" such as:

HKD, AED, KWD, SAR, PLN, DKK, RON and others ?

can be sent in a private message

They have spreads of half a day's movement.

 

Good afternoon!

Could you please tell me how to define TickValue?

 

I already have name defined:

if(!m_symbol.Name(Symbol()))) // sets symbol name

return(INIT_FAILED);

// double TTVV = double TickValue() const

How to get TickValue?