If the bot trades on different trading instruments at once, and it has periods when there are several open orders at some point in time. In a class that receives a General trading signal, depending on various factors, I want to remember the dates and times of the bar on which the trading signal was received and, accordingly, the trade was made. So this data, i.e. the date and time of the bar on which the trading signal was received, can be steamed during the execution of the program, if, for example, the program is reinitialized, depending on some factors. I decided that they should be saved after a successful transaction. If you do not do this, after reinitializing the program, I will have a transaction made on the same signal that has already been worked out. And this is not an option.
I decided to write this data to a file. Everything is logical here. But there is one point!
Here, for example, there is a bot that is running on some thread currency instrument, let’s say, AUDEUR. The second bot is also running on the same trading instrument. But each bot trades its own trading tools, registered in its settings. Not necessarily AUDEUR.
It turns out that if I write the date and time of the bar on which the trading signal was received in a file with the name of the bot, they will interfere with each other because they will overwrite each other’s data, if the flag when opening is FILE_SHARE_READ. The question arose, how best to identify the file, so that such a thing would not happen?
It is clear that this is not a frequent case, but it still needs to be handled somehow..
swan
The simplest thing is the input variables in the file name, those that will definitely be different in this case.
hoz
Not quite an option because my magic is dynamically calculated. At the stage of initialization of the program, you will have to calculate it, and this is not really an option. Although, .. such thoughts visited me too))
I walked today for half a day and thought about it in parallel. While I was wandering, I decided to use the file name + name of the trading instrument + TF in the folder with the bot name. How do we know the magic bot? You can, of course, calculate, but is it worth it?
vitales
And what prevents you from adding the name of the symbol to the file name and for reliability also the time interval of the chart on which your bot is located. Or even easier to add the “magic number” of the bot to the file name.
nektomk
Yes, as well as prevent conflicts of bots in the terminal. MAGIC.