This is the simplest solution I can provide within the limited amount of time I allocate for each free solution I provide in the Q&A Forum. There are three inputs to adjust based on the amount of time you want to include, the Fibonacci level you want to target and the direction you want the Fibonacci structure to be applied. There are severe limitations to this approach but this is all can provide here in the Q&A Forum free of charge.
The first input set the number of bars. For a 60 min time frame we have 7 hourly bars for each regular session. Multiply this by 20 days and we get 140 bars. If you include extended hours trade data in the scan you will need to adjust this input but for stocks you will find it nearly impossible to get that value correct.
The second user input adjusts the Fibonacci level you want to target.
The third user input is where you tell the code whether to compute that 61.8% retracement from the low or the high. When set to "up" the code is computing the levels as if the low occurs before the high. When set to "down" the code is computing the levels as if the high occurs before the low. This is the biggest limitation for this solution but I do not have time to include logic that checks which occurred first and adjust things automatically.
The signal itself simply checks of any portion of the current candle it touching the Fibonacci target level. The code has no way to know whether you want this signal to find stocks crossing above or below this level. Once again this limitation is the result having to build the simplest possible solution. We can do more, but not free of charge.
input barsToInclude = 140;
input fibonacciLevel = 61.8;
input fibonacciDirection = {default up, down};
def targetHigh = Highest(high, barsToInclude);
def targetLow = Lowest(low, barsToInclude);
def range = targetHigh - targetLow;
def targetLevel = if fibonacciDirection == fibonacciDirection.up then
targetHigh - (range * fibonacciLevel * 0.01) else
targetLow + (range * fibonacciLevel * 0.01);
plot scan = high > targetLevel and low < targetLevel;