My initial goal was to figure out the code. So I fired it up. As usual, it didn't quite behave the way I expected, so I started tweaking it. One thing led to another, and now we have another proverbial gun with which to look for trouble.
APRv02 (Automatic Profit Recovery) is typical of ALR family. It provides a steady source of income with daily risk of account blow up. But that's unavoidable. The risk, I mean. It's up to the trader to manage it.
[*] FLATTEN button is the only way to interact at this point.
[*] Trading hours are in broker time, because I don't like the confusion between local times on my development machine and VPS.
[*] VALUE displays cumulative profit for the ALR chain of tickets
[*] LOTS displays netlots for individual positions and total lots for the basket
[*] I've tested it for a day and I'm pretty sure there are no bugs. Don't report bugs.
Update August 4, 2022 --- APRv03
[*] Hibernate during rollover
[*] Hibernate deletes pending orders and removes stoplosses from open ordes
[*] Wake up restores stoplosses and recreates pending orders
[*] Look for ***ERROR*** in expert log if open order moved beyond stoploss.
[*] Spread/ATR(D1) filter: MaxCostToTrade