There are no "cells" and since you don't have any comma separated values you should use a bin file to read and write the entire array.
#include <files/filebin.mqh> void OnStart() { string file_name = StringFormat("Blacklist_%s.bin", _Symbol); if (writeOrders(file_name)) { int tickets[]; int total = readOrders(file_name, tickets); for (int i=0; i<total; i++) Print(tickets[i]); } } bool writeOrders(string file_name) { CFileBin f; f.Open(file_name, FILE_WRITE); if (f.Handle() == INVALID_HANDLE) return false; int tickets[]; for (int i=OrdersTotal()-1; i>=0; --i) { if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol) { uint index = ArrayResize(tickets, ArraySize(tickets) + 1) - 1; tickets[index] = OrderTicket(); } } f.WriteArray(tickets); return true; } int readOrders(string file_name, int &tickets[]) { CFileBin f; f.Open(file_name, FILE_READ); if (f.Handle() == INVALID_HANDLE) return WRONG_VALUE; return (int)f.ReadIntegerArray(tickets); }
There are no "cells" and since you don't have any comma separated values you should use a bin file to read and write the entire array.
Thank you so much, it worked!! :D
There are no "cells" and since you don't have any comma separated values you should use a bin file to read and write the entire array.
Although it correctly reads the ticket values from the bin files, I'd like to know how can I return the value of the tickets in order to set a condition like
if(OrderTicket() != TicketReturnedValue()) DoHedging(); else break;
I would write the infos into the file in another style, for example xml style:
<order1>188428</order1>
<direction1>buy</direction1>
then you can read them and sort them easyer
![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
Hello everybody, I'm trying to make my EA capable of assigning to an opened order in loss its specific hedging order so to avoid randomly opened hedging orders.
To do that I was trying to create a blacklist, blacklist which I thought i could do by simply using the FileWrite() function. So I came up with this, and it works:
What I now can't do, is reading each cell of the CSV the expert created and return the OrderTicket() value in each cell to another function. I was trying something like this, but none seem to be happening.
Can anybody please help me?