HN uses upvotes/(time_in_hours+1)^1.6*a_lot_of_penalties , where 1.6 is a number that may be changed by the mods without announcement. Comments are ignore, unless the post has too many comment and in this case HN adds a penalty. Flagging also adds a penalty once enough users flagged the post. And there are also other manual, and automatic penalties. Most details are secret and are part of the secret sauce.
You can create your own methods, but it's a editorial decisions. For example:
* Does comments move the post up, down, or not at all. Here in HN the idea is that too many comments is a sign of a flamewar, so one there are too many, it adds a penalty, but the mods may remove it.
* Is 1.6 the best exponent? A smaller number make popular post stay in the front page forever, a bigger value make recent bad post get too easy to the front page. Is 1.6 the best exponent? Nobody know. My guess is that it was chosen by experimentation until the got the result they like the best. And there is an alternative page https://news.ycombinator.com/best with another exponent (or something more strange).
* Number of views are ignored here, but it may be a good idea for other sites.