This is already available using standard built-in tools. Screenshot below shows how to set this up. I set the percent threshold to 0.1 because when a stock makes a new 50 day high it is likely to be fluctuating a bit. You will want to experiment with different values. A percent threshold of zero would require the price to currently trading at exactly the 50 day high at the moment the scan is run. So I suggest you go the other direction, 0.5 or 1.0.
Notice the key point that makes this work is the filter has been added to the "Condition Group" named "None of the following".
Edit: Based on further clarification provided in the comments section below I have a section of code to provide the solution.
input targetPeriod = 50;
def newPeriodHigh = high > Highest(high[1], targetPeriod);
plot scan !newPeriodHigh;
The target period is an adjustable use input. The code checks if the current bar's HIGH is greater than the previous target period HIGH. The plot statement on the last line uses the "!" operator which is the same as saying "Not newPeriodHigh". So we create a variable that is true when the undesiarable pattern is present. Then we write our plot statement to say "anything except that".
How is this different then my original solution using the built-in study filter as shown in the screenshot below? The built-in version checks the current price (the close of the candle) and does not check the high of the candle.