guerin remi
guerin remi

Reputation: 115

Pine-Script + Optimize with lower timeframe, backtest

I would to know if it is possible to make a more precise backtest by applying a lower timeframe to exit the order.

For example, I have a DAILY timeframe strategy, but exit transactions are done when the bar is closed and sometimes it is confusing when what the first Take-Profit or Stop-Loss is reached.

I tried to applicate a timeframe of one minute to affinate the Stop and Take-Profit trigger but it seems not to start in the same time of the begining of the backtest. I have plot One Minute time frame and it is programming to begin from the current time.

There is a solution to set the begining of 1 minute timeframe at the start date of the backtest ? Maybe through an upgrade of the account ? Pro toward prenium ?

Upvotes: 2

Views: 1762

Answers (2)

As of May 30, 2022; if you have a Premium TradingView account (the highest level) then you can make use of the new 'Bar Magnifier' feature (ref), which seems to allow for this finer grain accuracy:

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.

Upvotes: 1

PineCoders-LucF
PineCoders-LucF

Reputation: 8779

Your strategy runs on the chart's timeframe, and that resolution dictates the finest amount of detail your strategy can use to generate and process orders on historical bars. You can use security() to access higher timeframe information and use that in your calculations.

When your strategy runs in the realtime bar, then you have the option of enabling order processing at a finer resolution than the chart's resolution, using strategy()'s calc_on_every_tick= parameter, but keep in mind that while that will work for forward testing, your backtesting will not reflect that behavior, as historical bars on TV have only OHLC information.

Upvotes: 2

Related Questions