1

I am using premium subscription in tradingview, and developed a tradingview strategy for daily timeframe and it will place order after bar close when certain conditions are met, and once the order is placed, strategy.exit will only execute once triggered the stop or takeprofit level. I notice that Tradingview backtesting has a limitation that it will assume price action for each bar will simulate the following order: Open->High->Low->Close if opening price of bar is closer to the highest price of the same bar and Open->Low->High->Close if opening price of bar is closer to the lowest price of the same bar, so that if the next bar touches BOTH takeprofit and stoploss, it will ALWAYS assume the price reaching to takeprofit first if opening price of bar is closer to the highest price of the same bar which in real case it might not be true, can deep backtesting mode in tradingview mitigate the issues? If not, how can I change the following exit code show below such that it will check if the price trigger stoploss level or takeprofit level at the lowest possible timeframe available (e.g. 5mins or 1 min) instead of the current timeframe that I am using?

strategy.exit("TP/SL 1", "Long Entry 1",  stop = long_stop_level,  limit = long_profit_level)
strategy.exit("TP/SL 1", "Short Entry 1", stop = short_stop_level, limit = short_profit_level)
jguy
  • 161
  • 1
  • 11

1 Answers1

1

I think you're looking for the use_bar_magnifier parameter of the strategy() declaration:

use_bar_magnifier (const bool) When true, the Broker Emulator uses lower timeframe data during history backtesting to achieve more realistic results. Optional. The default is false. Only Premium accounts have access to this feature.

You can read more about it here:

Premium account holders can now obtain more realistic order fills in their strategy backtests by using The Bar Magnifier option. This tool uses intrabar inspection to obtain deeper granularity on price movement within a bar, allowing for more precise order fills. When selected, Bar Magnifier mode replaces the assumptions the broker emulator must make on price movement with only OHLC values for historical bars.

mr_statler
  • 1,913
  • 2
  • 3
  • 14