A trading algorithm consists of 3 parts - 1) the code to enter a trade 2) the code to close a trade and 3) the code to calculate how much to trade.