Trendoscope

Higher TF - Repainting + Limiting backtest results

Trendoscope Wizard Telah dikemas kini   
This strategy is for illustration purpose only. Do not use this as there is massive repainting.

As usual, I was experimenting with adding different entry/exit filters to my main strategy. Thought of adding higher frame filter, picked the code for getting higher time frame supertrend from someone else's script and copied it without thinking much about it.

security(syminfo.tickerid, f_multiple_resolution(HTFMultiplier), supertrend(SupertrendMult, SupertrendPd), lookahead = true, gaps=true)


  • Started getting better results with this result. I was very much impressed and while trying to enhance further, I started disabling my other entry and exit filters which I generally use.
  • That worked pretty well without any of my other filters. Hence, thought I will forward test this on a smaller timeframe.
  • To my surprise, even in forward testing, i was not able to notice repainting very much. It also appeared that smaller timeframes yielded better results. (This wasn't the case with any of my strategies)

Which then prompted me to study the security function and lookahead and gap parameters. Learned that lookahead and gap when set to true will lead to massive repainting - specially if you are using higher timeframes. Hence, these parameters are not advisable to use in strategies.

Further information here: www.tradingview.com/...curity_function.html

I added three repaint options to further illustrate how security function will work:

  • Yes : Use security with lookahead and merge set to true
  • No - set lookahead false : Use security with lookahead and merge set to false
  • No - do not use security : Falls back to original command on current timeframe. Switch timeframe to HTF resolution to compare the difference.

Conclusion : Always set lookahead and gaps to false when using security function in strategies.

PS: Script also contains code to limit backtesting to certain days/months/years. This can be used as is in other scripts.
Nota Keluaran:
Ok, there seems to be bit of misunderstanding from my side.

But, it looks like repainting is there whenever security is used and can not be avoided.

Hence, I split this into multiple parts:

1. Yes - Lookahead : true and Merge : true
2. Yes - Lookahead : true and Merge : false
3. Yes - Lookahead : false and Merge : false
4. No - Use no security.

Also, noticed that using previous bar calculation ( offset 1 ) yields same result for option 1 and 2. Only difference when merge is turned off is in the current bar.


I tried using these methods:
// f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src, lookahead = barmerge.lookahead_on)
// f_security(_symbol, _res, _src, _repaint) => security(_symbol, _res, _src)

As mentioned in the script:
But, these are not working with supertrend method.
Nota Keluaran:
Added further options to repaint to make use of f_security and f_secureSecurity functions:

// f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src, lookahead = barmerge.lookahead_on)
// f_security(_symbol, _res, _src, _repaint) => security(_symbol, _res, _src)

Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?