Hi!
I'm coding my very first EA, and i'm stuck with this issue:
I would like that evey time that i'm modifying the TP or SL, the Bot reply to the original message and send out a message with the update.
I've found this topic here, but i haven't understood it...
https://www.mql5.com/en/forum/347358
Do you have any idea on how to manage this issue?
Thanks, have a great day!
Hi .
Are you associating your ea trades to telegram message ids ? (and are these stored?)
Hi .
Are you associating your ea trades to telegram message ids ? (and are these stored?)
Currently i'm not associating anything... I'm just checking if the number of total orders (or pending orders) is increased, the BOT sends out the right message.
Thank you for your fast feedback!
Currently i'm not associating anything... I'm just checking if the number of total orders (or pending orders) is increased, the BOT sends out the right message.
Thank you for your fast feedback!
In general what it does is this :
- You post (anything) it returns a message # (if i recall)
- So you can utilize this when you are posting the first time about a trade and you can say i have this trade which is this message number in telegram.
- Then when you want to update about the trade you can instruct the bot to reply to the message number your ea has linked to an order.
- If you want to update the sl ,and it has already been updated once, you would not prefer to reply to the first message of the trade again but you would maintain the latest message # about that trade so it could make logical sense to the reader.
In general what it does is this :
- You post (anything) it returns a message # (if i recall)
- So you can utilize this when you are posting the first time about a trade and you can say i have this trade which is this message number in telegram.
- Then when you want to update about the trade you can instruct the bot to reply to the message number your ea has linked to an order.
- If you want to update the sl ,and it has already been updated once, you would not prefer to reply to the first message of the trade again but you would maintain the latest message # about that trade so it could make logical sense to the reader.
So basically to recap:
- Placing an order, the broker is giving me a number
- Than i have to figure out how to find the ID of the message sent by the EA on Telegram and merge this one and the number of the order.
- Write the code that if i'm modifying anything on the order, EA replaces the "mixed number" with this new one, with the same rule of point 2.
- Send out the message with the updated value modified
So basically to recap:
- Placing an order, the broker is giving me a number
- Than i have to figure out how to find the ID of the message sent by the EA on Telegram and merge this one and the number of the order.
- Write the code that if i'm modifying anything on the order, EA replaces the "mixed number" with this new one, with the same rule of point 2.
- Send out the message with the updated value modified
- Yes you open up a trade and the broker responds with a ticket (not -1 assuming mt4) , let's say 15455
- You then send a message with the bot and it tells you the message is #11 in the channel or the chat (if i recall ,haven't telegrammed a lot lately)
So now you can construct your own variable
struct myTradeInfo{ long order_id,message_id void reset(){order_id=-1;message_id=-1;} void set_order_ticket(long _new_order_id){order_id=_new_order_id;} void set_message_id(long _new_message_id){message_id=_new_message_id;} void save(int file_handle){ FileWriteLong(file_handle,order_id); FileWriteLong(file_handle,message_id); } void load(int file_handle){ reset(); order_id=(long)FileReadLong(file_handle); message_id=(long)FileReadLong(file_handle); } };
And then you can have an array(list) of these variables and add and remove from it as trades come and go , and also save it to the hard drive with an identifier unique to the ea , symbol and timeframe.
- Yes you open up a trade and the broker responds with a ticket (not -1 assuming mt4) , let's say 15455
- You then send a message with the bot and it tells you the message is #11 in the channel or the chat (if i recall ,haven't telegrammed a lot lately)
So now you can construct your own variable
And then you can have an array(list) of these variables and add and remove from it as trades come and go , and also save it to the hard drive with an identifier unique to the ea , symbol and timeframe.
Wow @Lorentzos Roussos thank you!
Now i have a little bit to study, I will type to you again and let you know if everything is working (i hope!) or not!
Thanks again
Wow @Lorentzos Roussos thank you!
Now i have a little bit to study, I will type to you again and let you know if everything is working (i hope!) or not!
Thanks again
awesome
Hi @Lorentzos!
Quick update:
I've had a look to the documentation you provided, and this is the result:
//FILE CREATION string OrderLog = "OrderLog.csv"; int OrderLogHandle = FileOpen(OrderLog, FILE_WRITE|FILE_CSV, ','); // Print error if file don't work correctly if(OrderLogHandle < 0) { Print("Error: ", GetErrorDescription(OrderLogHandle)); Sleep(10000); return(0); } // write header FileWrite(OrderLogHandle, "Order ID", "Open Price", "Open Time", "Symbol", "Lots", "Stop Loss", "Take Profit"); [...] Order Messages management and Text [...] // Write position on CSV file FileWrite(OrderLogHandle, OrderTicket(), DoubleToString(OrderOpenPrice(), _Digits), OrderOpenTime(), OrderSymbol(), DoubleToString(OrderLots(), 2), DoubleToString(OrderStopLoss(), Digits), DoubleToString(OrderTakeProfit(), Digits) ); FileClose(OrderLogHandle);
Now the problem is that the file is overwriting itself all the time, basically only updating the first line after the header.
How can I add rows, instead of overwriting them every time?
It's okay if it's deleting closed positions but I need to add the others....
Also I'm still trying to figure out how to get the id of the message I'm sending, do you have any advice on this?
Thank you!
Hi @Lorentzos!
Quick update:
I've had a look to the documentation you provided, and this is the result:
Now the problem is that the file is overwriting itself all the time, basically only updating the first line after the header.
How can I add rows, instead of overwriting them every time?
It's okay if it's deleting closed positions but I need to add the others....
Also I'm still trying to figure out how to get the id of the message I'm sending, do you have any advice on this?
Thank you!
Nice , so you will store your trades on csv only ?
That will make it more complex vs having it in a structure and saving it as binary when needed.(and loading it)
I will review the telegram code later , i'm really rusty on this one and let you know where the id is returned.
Nice , so you will store your trades on csv only ?
That will make it more complex vs having it in a structure and saving it as binary when needed.(and loading it)
I will review the telegram code later , i'm really rusty on this one and let you know where the id is returned.
Thank you! Do you have any idea on how to solve the problem of the append of the CSV file btw?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi!
I'm coding my very first EA, and i'm stuck with this issue:
I would like that evey time that i'm modifying the TP or SL, the Bot reply to the original message and send out a message with the update.
I've found this topic here, but i haven't understood it...
https://www.mql5.com/en/forum/347358
Do you have any idea on how to manage this issue?
Thanks, have a great day!