Tag Event Value Change Script triggering when it shouldn't

Greetings,
I have a tag event triggering at unexpected times. The following tag event value change script is on an OPC tag. The tag history doesn’t show values that meet this condition. Any idea what could be causing the event?
Thanks,
Ben

if not (initialChange) and currentValue.quality.isGood() and previousValue.value > 5 and currentValue.value <= 5:
system.tag.write("[.]…/…/HIP Q21/Run Trigger", 0)

|Dec 3, 2019 11:40 AM|3.98|
|Dec 3, 2019 11:40 AM|4.05|
|Dec 3, 2019 11:40 AM|4.13|
|Dec 3, 2019 11:40 AM|4.21|
|Dec 3, 2019 11:40 AM|4.29|
|Dec 3, 2019 11:40 AM|4.37|
|Dec 3, 2019 11:40 AM|4.44|
|Dec 3, 2019 11:40 AM|4.52|
|Dec 3, 2019 11:40 AM|4.6|
|Dec 3, 2019 11:40 AM|4.68|
|Dec 3, 2019 11:40 AM|4.75|
|Dec 3, 2019 11:40 AM|4.83|
|Dec 3, 2019 11:40 AM|4.91|
|Dec 3, 2019 11:40 AM|4.99|
|Dec 3, 2019 11:40 AM|5.07|
|Dec 3, 2019 11:41 AM|5.14|
|Dec 3, 2019 11:41 AM|5.22|
|Dec 3, 2019 11:41 AM|5.3|
|Dec 3, 2019 11:41 AM|5.3|
|Dec 3, 2019 11:41 AM|5.43|
|Dec 3, 2019 11:41 AM|5.5|
|Dec 3, 2019 11:41 AM|5.57|
|Dec 3, 2019 11:41 AM|5.64|
|Dec 3, 2019 11:41 AM|5.7|
|Dec 3, 2019 11:41 AM|5.77|
|Dec 3, 2019 11:41 AM|5.84|

Thanks,
Ben

Looks like you need to indent the “system.tag.write…” line.

I have it indented in the script. I just lost it in the copy/paste.

My problem is actually that the script is working when I don’t want it to.

Try moving the first open paren in your if statement to before the not keyword.

Consider editing your post to include triple back-quotes on lines above and below your code to trigger proper formatting and highlighting. Like so:

```
Some Code
```

Thanks for the heads up on the triple back quotes.

So instead of if not (initialChange) use if (notInitialChange) ?

Yes, (not initialChange). Note the space and exact case for initialChange.

If you didn’t work this out, you’re using .../ instead of ../ in your tag write. The former won’t work. Unless of course the forum replaced your two dots with three dots because you didn’t use preformatting…
Unrelated side note, you should use preformatting for all of your code!
e.g.

if not (initialChange) and currentValue.quality.isGood() and previousValue.value > 5 and currentValue.value <= 5:
	system.tag.write("[.]../../HIP Q21/Run Trigger", 0)