@Fabio Brondo try this , you needed to seek to the end of file and open it for read + write when it already existed
@Lorentzos Thank you! Sorry for the stupid questions below, but to be shure, i think that i have to modify the code in those points:
string system_folder="TELYBOT_",csv_file="the_file.csv"; //TELYBOT to be replaced with a path like C:\Users etc... and the_file.csv to be replaced with the name of the file?
intOnInit() // I currently don't have it on my code, where i have to put it?
void write_order_to_csv(int order_ticket,string _path){ //_path have to be modified with something again like C:/Users... ?
int f=FileOpen(_path,FILE_WRITE|FILE_READ|FILE_CSV,','); //instead of "f" I have to use the file name?
Print("Cannot select order "+IntegerToString(order_ticket)); // Order Ticket will be recovered automatically?
write_order_to_csv(ticket,system_folder+"\\"+csv_file); // Something- or what to modify here?
FileWrite(f,OrderTicket(),
DoubleToString(OrderOpenPrice(),sydigs), //sydigs, what is that? I've never see it before :(
OrderOpenTime(),
OrderSymbol(),
DoubleToString(OrderLots(), 2),
DoubleToString(OrderStopLoss(),sydigs),
DoubleToString(OrderTakeProfit(),sydigs));
Compiling your file returns 0 errors, but it's not recording nothig yet, not even generating the file...
@Lorentzos Thank you! Sorry for the stupid questions below, but to be shure, i think that i have to modify the code in those points:
Compiling your file returns 0 errors, but it's not recording nothig yet, not even generating the file...
My bad i did not give instructions of what it does . It places a trade on every new bar so to test it place it on an M1 chart and in 3 minutes you will have your test completed.
The system_folder is a subfolder inside "MQL4\Files\" , i am rarely using the common folder .
Is it a script you are running to execute trades ? (it has start?)
You don't have to modify the _path , you just send the file you want to write along with the folder if you wish to have files in a subfolder .
f is the file handle variable , if you are writing in one snap , that means the function runs opens the file writes and closes it (without it remaining open) , then there is no need to name it in a way that stands out from other file handles . Unless it helps you.
The order ticket must be sent to the function by you after you verify it was succesfully opened
My bad i did not give instructions of what it does . It places a trade on every new bar so to test it place it on an M1 chart and in 3 minutes you will have your test completed.
The system_folder is a subfolder inside "MQL4\Files\" , i am rarely using the common folder .
Is it a script you are running to execute trades ? (it has start?)
You don't have to modify the _path , you just send the file you want to write along with the folder if you wish to have files in a subfolder .
f is the file handle variable , if you are writing in one snap , that means the function runs opens the file writes and closes it (without it remaining open) , then there is no need
to name it in a way that stands out from other file handles . Unless it helps you.
The order ticket must be sent to the function by you after you verify it was succesfully opened
So if i've got your suggestion this part will look like this:
1:
string system_folder="C:\Users\[...]\MQL4\Files",csv_file="OrderLog.csv";
int tr=0;
datetime barstamp=0;
2. Yes, it has Start,init, deinit.
3.Ok i will keep _path
4. I don't care of the name, if it works :)
5. It will be like this:
if(Time[0]>barstamp)
{
barstamp=Time[0];
int ticket=OrderSend(_Symbol,OP_BUY,0.01,Ask,1000,0,0,NULL,0,0,clrBlue);
if(ticket!=-1){
write_order_to_csv(ticket,C:\Users\[...]\MQL4\Files+"\\"+OrderLog.csv");
}
Hi @Lorentzos Roussos, thanks for your help, now i'm able to store all the data in the CSV file!
I have one more question to you, i'm still not able to get the ID of the message that is sent each time a new order is opened or closed.
I'm currently using the bot.SendMessage function, do you know how i can get the ID of this message with this function?
Thanks for your support!
Hello .
Are you using the telegramL.mqh library ?
If you do there is a function :
int SendMessageGetID(bool replying_to_message,
long message_id_replying_to,
long _chat_id,//same as send message
string _text,//same as send message
string _reply_markup,//same as send message
bool _as_HTML,//same as send message
bool _silently,//same as send message
long &return_id)
which can be called like so :
string txt="i wear my sunglasses at nigh";
long last_message_id=-1;
int res=bot.SendMessageGetID(false,0,chat_id,txt,NULL,false,false,last_message_id);
The above will fill the variable "last_message_id" with the location of the newly posted message on the telegram chat (i.e. first second third post etc)
You can also check if it succeeded if it is bigger than -1 (if last_message_id >-1)
Conveniently , when you want to reply to a message you can use the same function , turn replying_to_message to true and dump the message id you have storred in message_id_replying_to
The above will fill the variable "last_message_id" with the location of the newly posted message on the telegram chat (i.e. first second third post etc)
You can also check if it succeeded if it is bigger than -1 (if last_message_id >-1)
Conveniently , when you want to reply to a message you can use the same function , turn replying_to_message to true and dump the message id you have storred in message_id_replying_to
Yes, i'm using the Telegram.mqh library but i'm starting thinking that i've found an already edited version... You can find it attached...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you! Do you have any idea on how to solve the problem of the append of the CSV file btw?
i'll try that now since thats the method you want to utilize and let you know . ☕️
Thank you! Do you have any idea on how to solve the problem of the append of the CSV file btw?
@Fabio Brondo try this , you needed to seek to the end of file and open it for read + write when it already existed
@Fabio Brondo try this , you needed to seek to the end of file and open it for read + write when it already existed
@Lorentzos Thank you! Sorry for the stupid questions below, but to be shure, i think that i have to modify the code in those points:
Compiling your file returns 0 errors, but it's not recording nothig yet, not even generating the file...
@Lorentzos Thank you! Sorry for the stupid questions below, but to be shure, i think that i have to modify the code in those points:
Compiling your file returns 0 errors, but it's not recording nothig yet, not even generating the file...
My bad i did not give instructions of what it does . It places a trade on every new bar so to test it place it on an M1 chart and in 3 minutes you will have your test completed.
My bad i did not give instructions of what it does . It places a trade on every new bar so to test it place it on an M1 chart and in 3 minutes you will have your test completed.
So if i've got your suggestion this part will look like this:
1:
2. Yes, it has Start,init, deinit.
3.Ok i will keep _path
4. I don't care of the name, if it works :)
5. It will be like this:
So if i've got your suggestion this part will look like this:
1:
2. Yes, it has Start,init, deinit.
3.Ok i will keep _path
4. I don't care of the name, if it works :)
5. It will be like this:
You don't need to send the C:\users... stuff , it will take care of it on its own.
Hi @Lorentzos Roussos, thanks for your help, now i'm able to store all the data in the CSV file!
I have one more question to you, i'm still not able to get the ID of the message that is sent each time a new order is opened or closed.
I'm currently using the bot.SendMessage function, do you know how i can get the ID of this message with this function?
Thanks for your support!
Hi @Lorentzos Roussos, thanks for your help, now i'm able to store all the data in the CSV file!
I have one more question to you, i'm still not able to get the ID of the message that is sent each time a new order is opened or closed.
I'm currently using the bot.SendMessage function, do you know how i can get the ID of this message with this function?
Thanks for your support!
Hello .
Are you using the telegramL.mqh library ?
If you do there is a function :
which can be called like so :
The above will fill the variable "last_message_id" with the location of the newly posted message on the telegram chat (i.e. first second third post etc)
You can also check if it succeeded if it is bigger than -1 (if last_message_id >-1)
Conveniently , when you want to reply to a message you can use the same function , turn replying_to_message to true and dump the message id you have storred in message_id_replying_to
Hello .
Are you using the telegramL.mqh library ?
If you do there is a function :
which can be called like so :
The above will fill the variable "last_message_id" with the location of the newly posted message on the telegram chat (i.e. first second third post etc)
You can also check if it succeeded if it is bigger than -1 (if last_message_id >-1)
Conveniently , when you want to reply to a message you can use the same function , turn replying_to_message to true and dump the message id you have storred in message_id_replying_to
Yes, i'm using the Telegram.mqh library but i'm starting thinking that i've found an already edited version...
You can find it attached...
Do you have a "clean" version?
In mine there is no function SendMessageGetID
Yes, i'm using the Telegram.mqh library but i'm starting thinking that i've found an already edited version...
You can find it attached...
Do you have a "clean" version?
In mine there is no function SendMessageGetID
Oh , the TelegramL.mqh The clean version does not have the get message id modification .
Here is the latest