When shifting gear on my mtb sometimes the chain sticks between cogs and other times it does not move immediately .Would be glad of any advice as it is very annoying I managed to stop to have a look and the chain sort of balances between the cogs.It will eventually fall on to the cog with a clunk although sometimes when I move the lever nothing happens at all and when I move it again it changes two gears.This is always on the smallest or second smallest rear cogs and usually changing up
From what you describe, the problem could the B-screw (derailleur tension screw).
If the derailleur tension is set too low (screw too tight), the chain sits too far from the sprockets and it can have trouble jumping from one sprocket to the other, especially on the smaller ones. Otherwise, if the screw is too loose, the upper pulley can be too close to the sprockets and shifting to the biggest sprockets could be a problem. Remember, the derailleur upper pulley should sit close enough to the smallest sprockets, but not so close to touch the cassette when the biggest sprocket is set. The more speeds the cassette has, the bigger the gap can be: it can be 2 mm on 7-8 speed cassettes, or even 6 mm on 11-12 speed cassettes (obviously the more the teeth on the bigger sprockets, the more the gap is)
Another problem that can cause similar symptoms is when the chain has too many links or if it's too worn out: if the chain is too long, it will have trouble sitting near enough to the cassette, no matter how much you adjust the B-tension screw.