[Prod] SuperTrend with Stoploss+TrendZones - 1H

Here, i'm using a SuperTrend (difference of moving averages) crossover strategy hybrid with stop-loss and trend-following to look at backtesting for the BCHUSD pair on the coinbase (GDAX) exchange.

Included in this script I've got some optimized parameters that seem to make a decent profit over ~35+ trades. The one thing that's bothering me here is that I get OCCASIONAL repaint issues with back-testing, but I can't figure out why for the life of me, because i'm using V3 in the start of the script. If someone could point out the mistake I may be making here , I feel like this could be a serious strategy to use against the BCHUSD pair on coinbase or other exchanges (with tuning of course).

I based this script off of with lots of modifications.
즐겨찾기 스크립트에서 빼기 즐겨찾기 스크립트에 넣기


Without using the security function, it doesnt seem possible to calculate my strategy on the proper DEMA timescale.. which sort of undermines the whole point. PineScript 3 was supposed to have fixed this problem.. but it seems like it has not somehow..
Also, let me know once you have fixed this and you still see the profits you are seeing - I have improvements to share - if you would so like.
Do NOT use `security` function. Period. No repaints.
NikhilGuptab4 NikhilGuptab4
@NikhilGuptab4, if you need to access higher timeframes - create the calculations yourself.
Note: Here's a link that demonstrates that a repainting problem is occurring in the DEMA lines.. even though it shouldn't be. This is the problem i'm trying to solve:
P.S. I've commented the code reasonably heavily. I believe that the problem may lie in the Securities/EMA function based on some careful watching i've done... as it's the only one that could have an issue like this.

I would also appreciate any comments from traders who might know how to optimize gains during uptrends, which this long-only strategy seems to have trouble with, even with detection of up/down trends. It's possible that a completely different strategy should be applied during uptrends vs downtrends and that the DEMA+stoploss strategy that works for general downtrends and sideways markets is poor for uptrends.

Ideas for improvement ?
If anyone knows how to troubleshoot potential backtesting / repainting issues with V3 of pine script here, I'd love a hand. I can't seem to figure it out.
홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 프렌드 리퍼하기 하우스룰(내부규정) 헬프 센터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 라이트웨이트 차팅 라이브러리 블로그 & 뉴스 트위터
프로화일 프로화일설정 계정 및 빌링 리퍼드 프렌즈 코인 나의 서포트 티켓 헬프 센터 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃