Generalized Trading Bots

Trading Strategies / Bot Setups
Feature Requests

Currently a bot deal is a meta object that under the hood groups several orders to manage the risk. We call those orders initial buy order, safety order, (partial) stop loss and (partial) take profit. And we call the deal closed as soon as we have a complete stop loss or take profit.

In case of take profit that’s clear because the meta object deal has given us some gains.

But what about the stop loss? Why shouldn’t we be able to also use that to later close our meta object “deal” with take profit? But how - isn’t a stop loss a realized loss? Shouldn’t that be the end of a deal then? Shouldn’t we better use safety orders to not realize the losses and finally close the deal in profit.

Well, from my perspective safety orders surely have their place. And dynamic safety orders that are even placed according to indicators and auto-scaled for a configured required change to take profit surely improve the fund usage. But holding on a losing deal and to offset those losses with an accordingly scaled safety order isn’t the most fund efficient way to do it.

Martingale safety orders

What if we would see stop loss as part of the meta object deal that doesn’t close the deal. Then we could prevent the deal from collecting further losses. And as indicator placed auto-scaled dynamic safety orders do, we could re-start the deal by placing an indicator placed auto-scaled dynamic martingale order that requires less funds than the safety order because it has to offset smaller losses than the safety order.


  • Martingale safety orders require at most as much funds as a usual deal with safety orders.
  • Because of that the required change could be smaller
  • We even weren’t bound to continue trading the same pair but could execute martingale safety order on another more promising pair (even though than we properly had to speak about a pool of deal meta objects, where new deals check other deals losses to scale their base order)

If for safety orders holding to losses can be a risk it can also be a chance to possibly catch spontaneous reversals to close the deal if the safety order levels fit into the market context. On the other hand, martingale safety orders could also catch the reversal.

Imagine that:

With the already existing dynamic price filter we could built an Trading Bot order grid where every deal would use martingale safety orders and quickly limit the losses of each deal and re-gains those with connected Martingale deals in a fund efficient way. What else could we wish for?

For those interested: What’s about the math behind it?

It’s all done and ready to use and could be shared from my side.

Chat with Google Gemini about above concept.


I don’t understand this part. Also the math seems counterintuitive. If I understand this correctly, you propose to not close the deal when it reaches the SL (which then should not be called Stop Loss, as it doesn’t perform that function anymore), and instead wait for an indicator to give a signal and open a safety order that is smaller (than the base order?) because it has to offset smaller loses (what loses does it need to overcome?).

I think it would be useful if you can provide an actual example with specific prices. When does the bot open the base order, at what price buys more and what quantity, the resulting new average price and the new take profit.

Yes, probably I also should have called that stop loss, that does sell the assets but doesn’t close the deal, a Martingale stop loss to show the connection to the Martingale safety order and keep the possibility to still configure a usual stop loss - if those two could be combined in a bot setup.

I will add an example later that compares usual safety orders with those Martingale safety orders.

Comparison of

Usual safety order as we already know it from Trading Bots Martingale safety order with a Martingale stop loss
. .

image image

And with a little gap in between

image image

Another Pro, that I don’t want to leave unmentioned, is that we could even relax our understanding what the meta object deal allows even further. I.e., with the Martingale stop loss we aren’t bound to re-gain the temporary losses with a reversal on the exact same pair. The losses could go into pool from which follow-up deals on every configured pair could decide to regain some by starting with a Martingale safety order.

Ok I think I understand the concept. Put in other words, when one deal hit SL, the next one opens with the negative P&L carried from the previous deal and the mission is to overcome the negative P&L (breakeven in the two).

However, I don’t see how this logic is better than what you can do with the existing system. In fact, I think it looks more like gambling than a trading strategy. The point of a trading strategy is that you have a series of independent events (trades) that yield probabilistic results over a long enough period. The key here is “independent”; starting a trade with settings that depend on the previous trade is not an independent event. The backtest wouldn’t be reliable, and on top of that, it’s giving users more cognitive strain trying to understand what this is for and if they need it in their strategy.

The implementation of a new logic needs to follow some guidelines, otherwise it can do more harm than good.

And before you say “but I am not suggesting to open two deals, is just one deal”, I can already answer, yes but the execution is exactly the same, whether you want to count it as one deal or multiple.

In any trading system, when one deal hit SL, the last thing you should do is open others just because that one deal went wrong (call it revenge-trading, but it can be applied to automated systems). The best course of action is in fact to continue following your plan and open a new deal when the rules confirm, with the same SL and TP rules. By doing that, you continue to expect the same probabilistic outcome.

Of course, we had to also limit the number of Martingale safety orders as well as the amount of used funds as we do it for regular safety orders. On the last Martingale safety order we could decide whether we want to keep the deal open as we possibly would do in case of a failing set of regular safety orders.

The difference to regular safety orders is that Martingale safety orders require a lot less funds as above pictures show. The first two pictures show that a regular safety order uses the same amount of funds as a Martingale stop loss and Martingale safety order at the exact same position. The second two pictures show that with an early Martingale stop loss we require less funds to gain $10.20.

So why exactly do you think that Martingale safety orders are gambling while holding to a losing deal and using regular safety orders isn’t?

Because as I understand how probability works, backtest can only be trusted when the events are independent. I already looked it up when I was thinking about adding a system that doubles the volume in the next deal if the previous one resulted in a loss. After much thinking, I decided not to go ahead. This falls on the same category.

When you change the volume, TP, and SL of your next position based on the outcome of the last one, you multiply the level of randomness introduced in the strategy.

To be able to consider this I would need to see mathematical proof that I’m wrong.

I called it Martingale but it isn’t about doubling the deal size as classical Martingale deals do.

That’s what regular safety orders do as well. You increase the deal’s volume by adding funds of the current deal to reduce the required change to take profit. As soon as we have executed the safety order, the resulting required change becomes the implicit take profit of the deal. That usually differs from the initial take profit more or less depending on how much funds were added. If we wanted the safety order to reduce the required change to match our initial take profit, we couldn’t pay for it.

The “Martingale” safety order uses at most as much funds as the deal with a regular safety order would do to achieve the same resulting required change. If all deals of this bot run with the same setup, I don’t understand the last part about the SL. The SL would be the same for all deals of this bot.

Correct, but you are proposing to take the TP of the martingale safety order to offset the current loss, which means that TP depends on the loss accrued by the previous position.

Even assuming that I am wrong and they can be considered independent events and backtested, the biggest hurdle for this logic is that I don’t think that it provides enough benefits to justify the developing, testing and maintanenance of this logic. I don’t see how adjusting your next deal to overcome the loss of the previous conveys any advantage, you would be always struggling to break even.

This is only true in some cases. If the price rebounds before opening the next safety deal, you would have accrued the loss of the previous deal and missed the opportunity to take TP.

That’s why I wrote above