Trading Bot - Long or Short

A Trading Bot is designed to work in Bullish Up Markets as well as in Bearish Down Markets. The visual below highlights the difference between a Long Trade and a Short Trade

  • Long Trade - This is the traditional Trade - the objective is to Buy Low and then Sell High - making a profit

  • Short Trade - The reverse of Long, a Short Trade swaps the two steps and initiates a Sell High and when the price drops, you Buy Low

  • Note; In both, Long & Short, the right objective is Buy Low/Sell High. Aiming for a Buy High/Sell Low is a recipe for disaster

Trading Bot - Order Flowchart

A Trading Bot has 3 key orders that work in conjunction with one another.

  • The first, is the Entry Order - which is initiated in the ‘Submitted’ State. As soon as the order is executed, it Triggers a pair of orders as a Bracket Order.

  • The Bracket orders include a Profit Order and a Stop Order which will cancel the other order when the Price hits either the Profit or Stop Order value.

  • The graphic below captures this flowchart of Orders that facilitates the creation of a Trading Bot

Trading Bot - State Diagram

A Trading Bot needs to be designed to work continuously. As such, it must be able to handle 4 main states as listed in the detailed visual below

  • Initialization - This is the starting point for the Trading Bot

  • Pre-Trade - The second phase occurs before we enter a Trade, or the Entry Order

  • In-Trade - This phase establishes a Long or Short position, and as the visual above highlights - we need to manage the Profit & Stop Orders

  • Post-Trade - Final phase, when the price either hits the Profit or Stop order values (or a Winner/Loser trade) - we need to clean up, reset and get ready for the next Trade

The above visual may appear as a daunting task to undertake, especially to non-programmers - this is where AI coding tools come in handy. With Vibe coding you can create smaller code blocks (corresponding to the above visual) and then assemble them for the complete Trading Bot. AI coding tools are also very capable of auditing the entire Trading Bot and ensuring the appropriate dependencies are fixed.