Could be something to do with the MTF and its actually running on a secondary series you're not charting? Or are you?
As far as checking how many bars back that swing low is you could do something simpler such as when the value changes mark that bar as the start of a new swing by storing "CurrentBar" into some variable. Then check against that variable versus current bar to see how many bars has passed since it was set?
If still running into issue only thing you would be able to do is to take a look at the script running out of idea's with the information provided so far.
Comment