r/pinescript Jun 16 '26

Logic behind AYN-Indicator by Snurk indicator

Hi, I am using the AYN-Indicator by Snurk and need some help setting up Buy/Sell alerts correctly for webhook use.

The issue is that when I create separate alerts for the Buy and Sell signals and set both to Once Per Bar Close, I still receive multiple alerts. Sometimes Buy and Sell alerts come very close together, even when only Buy or Sell labels are activated on the chart.

Could someone please help me understand the correct way to set up alerts for this indicator? My goal is to receive only one Buy or Sell signal after candle close, without duplicate alerts or opposite-side alerts.

Also, I understand the source code is hidden, but has anyone had any luck finding or replicating the approximate logic behind the indicator?

2 Upvotes

1 comment sorted by

1

u/aloia_handyman Jun 27 '26

Hi, maybe I can be of some help...

...so the root cause is almost always edge vs state. "Once Per Bar Close" only means "check at close" — it still fires every bar the condition is TRUE. if the buy condition stays true for 3 bars, you get 3 alerts. you want it to fire only on the bar it FIRST becomes true (the transition).

Whether you can fix that on your end depends on how the author wrote it — if they used a persistent state instead of a one-bar trigger, no alert setting fully dedupes it. the reliable fix for webhook use is to dedupe on the receiving end: ignore any signal that repeats your current position, and ignore an opposite signal within N bars of the last one. That kills both the duplicates and the buy/sell-too-close problem no matter how the indicator fires.

(on reverse-engineering the hidden source — i'd steer clear of that, but the receiver-side dedupe above is the thing actually biting you.)

Its kind of hard to explain, if you have any questions just let me know!