Other answers mentioned this, so I won't go into too much detail on this point, but this battle may not need to be fought. If the valley is the only practical access point between these two countries, and the protagonist is fighting for independence, then holding this valley might be enough to force the enemy to negotiate terms. However, assuming that for political reasons the main enemy force needs to be defeated decisively, here we go...
This battle hinges on the protagonist being able to position his forces such that they are able to defeat the enemy reinforcements when they arrive. One position would be the castle (obviously). Another option would be to march past the castle, and position his troops at the opposite entrance to the valley. This would give them time to dig some fortifications and occupy the high ground (relative to the enemy reinforcements) while also constructing siege equipment.
A lot hinges on just what exactly defines the "heavy cavalry". Even in the late Middle Ages to Early Renaissance there was a wide variation in heavy cavalry, with the heaviest being eastern cataphracts employed by the Romans (Byzantines to us). Furthermore, it is not just the equipment of this cavalry that determines their combat value, but also their training and discipline.
Armored troops are generally fairly safe from archers, except at point blank range. Most arrows were not of high quality, and most archers were not particularly well trained (except for professional troops, such as the English yeomen archers of lore). A commander who anticipates making heavy use of his archers will invest in their training and attempt to purchase high quality arrows, but these are not always available or up to standards (a common complaint of English commanders during the Hundred Years War).
So while the archers may be able to injure the horses of the heavy cavalry, the men themselves (knights? or are they professional troops?) have little to fear from archery. While pikes traditionally are a good defense against cavalry, they are by no means foolproof. The Polish Hussars are a good example of heavy cavalry who excelled at breaking infantry formations in a head-on charge. This was due largely to their skill at maneuvering in tight formation and repeatedly charging.
The terrain of this valley may preclude such tactics, in which case the cavalry commander would likely remain in the castle. If he is unable to charge repeatedly to break the protagonist's infantry, he has no reason whatsoever to leave the castle. His troops are likely well armored and would serve equally well defending the walls as they would mounted on horseback. Unless he has made gross tactical errors, he likely had scouts watching the valley approach and will be aware of the protagonist's forces.
Logically, if he is a disciplined commander, he would dispatch messengers to the main army informing them of the situation and the composition of the protagonist's forces. Then they would wait for reinforcements, or to repel an attack on the castle. You need only look to the crusades for many instances of armored knights holding castles for long periods against larger armies for an idea of how this situation would play out. No such concepts as "honor" and "chivalry" would compel them to engage in a suicidal fight. Throw aside all that nonsense that Hollywood and Sir Walter Scott made up about "Lawful Stupid" knights. Medieval nobility and their men at arms were lifelong warriors, and while oaths of allegiance were very important, in no way did they interfere with commonsense tactics and strategies.
The only situation where the enemy cavalry commander would attack would be if he felt that his forces had a very good chance at routing the protagonist's army. However, if he lacks good knowledge of the protagonist's forces, then it is likely that the protagonist lacks good knowledge of his forces. I saw another answer indicating the 'lack of light cavalry' would make scouting difficult for the enemy commander. That's nonsense. He's in a valley, he has horses. He will watch the approach and have scouts make note of the protagonist's approach unless he is hilariously incompetent (which is always possible, if you want).
So, the way for the protagonist to defeat the main enemy body is through positioning. If he can cut off the castle, and isolate its defenders, he has a reasonable chance of holding the valley entrance against the approaching reinforcements. The castle itself is unlikely to do him very much good, since even if he took it that would just leave him vulnerable to a siege by a larger force free to cut him off from resupply.
By holding the valley entrance, the protagonist is able to maintain his lines of communication back home and also to prevent the enemy army from moving through the valley (where they could cut him off). His archers will benefit immensely from the high ground, and his light cavalry can easily maintain the siege of the castle while still being available to reinforce the main army if needed desperately.
The resolution to this situation would come either when the enemy chooses to assault his position (fortified with the benefit of several days, and uphill at that) or if the enemy declines battle, the castle would eventually have to yield. Given the winter weather, the enemy force would need dramatic materiel superiority to succeed in an uphill assault against a fortified position. If the enemy force truly is strong enough to dislodge the protagonist from that position, then they should probably withdraw and fight a guerrilla campaign.
As I see it, holding the valley entrance is the strongest position for the protagonist to take, and it expends the least amount of effort/casualties to occupy. There is a slight risk that while they are bypassing the castle the cavalry may sally forth to attack, but this risk exists no matter what course of action the protagonist takes.
Hope that this analysis helps, and be sure to consider the training/experience of the troops with different scenarios (the sappers would surely be helpful in preparing fortifications for the protagonist, for example).