TradingView
and_then_it_CRASHED
٨ تشرين الثاني نوفمبر ٢٠٢٢ ١٣:٣١

Backtests Are Broken 

(BTCUSDT+BTCUSD)/2Binance

الوصف

This script demonstrates a fatal flaw with Trading View backtests involving trailing stops. Trading View assumes the most optimistic case for trailing stops, always giving you the best case high/low of a bar instead of the worst or average case. Within a bar, the price could reverse against your position after the open and trigger your trailing stop for a loss before the price goes in your favor, but Trading View backtests do not consider this and instead always give you the best case returns. This allows a trivial strategy to appear as though it would perform miracles.

This strategy enters on a random bar and sets a trailing stop triggered one tick better than the current price with 0 trailing distance. Trading View then generously gives this strategy the difference between the open price and best possible wick as a profit. The only way this strategy can lose money in simulation is if the price goes straight down after entry and never retraces. It works on all symbols on all timeframes due to this systematic problem with the Trading View backtester.
التعليقات
PineCoders
Thx for this. We reported it to the Pine team and will keep you posted here.
and_then_it_CRASHED
@PineCoders, Sorry if I sounded snarky. Backtesting is hard. What even IS the average case for this bar? Unless the trailing stop activates with one bar lag, the distribution of outcomes is hard to model without dropping down to shorter timeframes to sample outcomes. Even then, there's variance within the bar that activates the trailing stop. Maybe just the average of up-then-down and down-then-up cases would work to first order. Half the time you get up-then-down and half the time you get down-then-up. Far from perfect but it should fix a good bit of this pnl bias with a minimal change.
and_then_it_CRASHED
@PineCoders what if you always give 0 profit to a same-bar trailing stop that triggers? Older trailing stops get the open price minus the trailing distance? This would be a more conservative way to handle it.
and_then_it_CRASHED
@and_then_it_CRASHED, Also why even allow a trailing stop of 0 ticks? Shouldn't 1 be the minimum allowed value?
Jean-FrancoisLeBas
who knew the holy grail would be only 4 lines long
XD
it's as broken as Heiken Ashi backtests !
user1928374560XYZ
@Jean-FrancoisLeBas, can you explain the concept more?
PineCoders
The fix resolving this problem was just released. @and_then_it_CRASHED, Thx again for mentioning the issue.
christiano88
Was this fixed?
PineCoders
CXRB0N
What about Deep backtesting and Bar magnifier? If they're enabled, does trailing stop work or not?
المزيد