Cockatiel moodswings

I recently bought a cockatiel from a pet shop that was dropped off there by a lady who couldn't care for him any more, he was extremely friendly in the store, a couple days later i brought him home and he was acting a little withdrawn, whenever i have him out of his cage he's sociable and not incredibly scared of his new surroundings, but when he's in his cage, he gets really defensive, he climbs into one corner and gets in a fighing stance, but if i leave the room he stops immediately and starts calling out to me, are these sudden mood swings normal?