QuantNomad

Parabolic SAR Strategy (on close) [QuantNomad]

Created a Parabolic SAR strategy where price has to close under/above the level before for it to reverse. This way it should be a bit more stable and protect you from false breakouts.
It was impossible to adjust the built-in "sar" function so I implemented PSAR from scratch. So if you're interested in how it's work inside you can check the code and probably adjust to your need if you have a custom modification of PSAR in your mind.
Phát hành các Ghi chú: Added "Entry on Nth trend bar" parameter. Now you can specify on which trends bar do you want to reverse position. That can help you to filter out noice and skip 1-2 bars trends.
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
Courses:
PineScript Programming: https://qntly.com/pinepro
TradingView Essential: https://qntly.com/tve

Pro Indicators: https://qntly.com/proind

YouTube: https://qntly.com/youtube
Discord: https://qntly.com/discord
Telegram: https://qntly.com/tel

Bình luận

Hi @QuantNomad , thanks for sharing this. I have been manually looking at PSAR as an indicator for awhile now and came across your strategy here. I'm thinking of ways to reduce the noise of the entry/exit triggers and am wondering if having a long/short entry only if the PSAR has had 3 consecutive plots in the same direction (i.e. 3 green or 3 red) would work. What do you think? I'm keen to test it out but not sure how to edit your existing script to reflect this amendment. Can you advise? Many thanks in advance
Phản hồi
QuantNomad yeojingcheng
@yeojingcheng, hm well it might work. I will take a look when will have some free time.
you can try something like this:

strategy.entry("Long", true, when = trend_dir == 1 and trend_dir == 1 and trend_dir == 1)
strategy.entry("Short", false, when = trend_dir == -1 and trend_dir == -1 and trend_dir == -1)
Phản hồi
Hi, first of all thanks for sharing with us plebs your script. I have a question as to recognize where exactly the longs or shorts are closed. Because with the small arrows it is not clear, at least for me. I look forward to hear from you.
Phản hồi
QuantNomad giacomo.ferrari15
@giacomo.ferrari15, order is executed on close of the bar which broke PSAR. By default orders are filled on open of the next bar.
Phản hồi
hmmm study based on this gives a repaint warning, any reason for that?
Phản hồi
Is it possible to adjust the script so that the starting point of the new trend is the respective closing price instead of the high/low?
Phản hồi
why not to use when=crossunder(psar, close) for long (crossover(psar, close) for short ) using built-is sar function ?
Phản hồi
QuantNomad pabloses
@pabloses, Because in built-in sar function you have condition included that on touch it will revert. As result your receive both trend up/down levels in same var calculated with "touching" logic. So there is no way to use standard sar function for that.
+1 Phản hồi
pabloses QuantNomad
@QuantNomad, Thanks, I understand. Your script actually ignores wicks.
Phản hồi
Great!
Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Cách thức hoạt động Tính năng Biểu đồ Trả phí Giới thiệu bạn Quy tắc Áp dụng Trung tâm Trợ giúp Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Blog & Tin tức Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất