There are cases when you need to save the trade history. Sometimes it's unavoidable. However, it is risky and requires constant attention.
A Few Tips on How to Do It Right.
1. When Do You Need to Save Trade History?
Generally, there are two situations:
1. When you're trading on that history and need deep historical data.
2. When you're trading on non-standard candles and have an unwise habit of occasionally changing timeframes. If you change the timeframe and the trades are not saved, non-standard candles will start building from scratch!
2. How to Enable Saving Trade History?
Each trading connector in OsEngine has standard settings where you can enable trade history saving. A large article about this is available here.
In any connector, these three settings are responsible for it:
Save Trade History (Keep trade history).
If true, OsEngine stores all the trade history it receives in the OsData folder.
Load Trades for Days (Days to load trades).
This relates to the previous setting. If you have enabled trade history saving, you can adjust this setting to specify how many days the trade history will be kept.
Remove Trades from Memory. (Remove trades From Memory).
This functionality periodically clears all trade history storage in the robot’s memory. If you need trade history, you should set this to False.
Tip 1: Don't Do This on Multiple OsEngines.
This is actually the crux of the matter:
A colleague from the OsEngine community was trying to figure out the best way to trade with trade saving enabled and launched four instances, distributing the robots among the terminals. In each terminal, there are about 100 sources!
So, if you are saving trade history, multiple concurrently running OsEngines will worsen the situation!
The problem is that instead of consolidating the trade history into one database, OsEngine will attempt to do this simultaneously in four!
Therefore, tip number one:
Do not save trade history from different terminals simultaneously. Do this in a single build.
Tip 2: You Will Need to Restart OsEngine Several Times a Week.
Yes. In this case, you will have to restart the terminal so that the "excess" used memory is cleared and only the N days for saving specified in the connector settings remain.
This way, you can control the RAM usage.
In general, that’s it. You can save trade history, but you will have to monitor it and follow some rules described in the article.
Happy Algorithms!
OsEngine Support: https://t.me/osengine_support_english