There are many definitions of the word ‘Algorithm.’ Here are a few examples:
A plan consisting of a number of steps precisely setting out a sequence of actions to achieve a defined task. The basic algo is deterministic, giving the same results from the same inputs every time.
A precise step-by-step plan for a computational procedure that begins with an input value and yields an output value.
A computational procedure that takes values as input and produces values as output.
Here we should mention ‘parameters.’ These are values usually set by the trader, which the algo uses in its calculations.
In rare cases the parameters are ‘adaptive’ and are calculated by the algo itself from inputs received.
The right parameter setting is a key concept in algorithmic trading. It makes all the difference between winning or losing trades.
Unconsciously we create little algorithms without having any recognition that we are performing mathematical applications all day long. The brain supercomputer carries it all out without us being aware of it to the slightest degree.
Now let’s finally get back to trading. Here is an over-simplified algo example.
You want to buy 1000 shares of Apple (ticker symbol AAPL) and you are looking at a real-time data feed. The Time and Sale is printing mostly 100 volume lots hovering between $178.50 and $179.00 – but a few minutes ago it dipped to $177.00. So you
decide to set your Buy algo the task: BUY 1000 shares AAPL at MARKET if trade price touches $177.00
Now for a slightly more complex example for which we would need a number of components. For the moment, just imagine these:
A real-time data feed (not from one of the 15 minutes’ delayed variants). This feed consists of the stock ticker symbol to identify it, the timestamp of when the trade was executed, the number of shares (volume) which has changed hands and finally the trade price as matched up by the buyer and seller who may be represented by their respective brokerages. All this happens in what we call the ‘electronic pit.’
The ‘electronic pit’ image (thousands of traders who at that instant are looking at exactly the same data on their screens that you are also looking at) we find exceptionally useful in visualizing the price movement of a stock.
In our application a fully fledged real-time data feed is fed to an Excel template populating an Excel Spreadsheet. The template has an embedded set of Excel function language calculations (basically an algo) which Excel recomputes every time new data comes in. The algo is designed to ‘trigger’ when a certain calculation parameter attains a ‘BUY’ condition. You see this on the spreadsheet and put on the trade manually using your order management system (OMS).
In the future, we may be able to get it all done with a fully automated software subroutine with the computer taking on the order placement task for the individual trader single-handed, just as now performed by the big players of the moment!
We have purposely left the placing of orders in manual so as to accelerate the learning process and give you a firm foundation to build on.
One of the most crucial steps to profitability and the most difficult one to master, requiring beside experience and skill, a good helping of old-fashioned trial and error, or better yet, trial and success.
The next most important step to achieve profitable trading is to put on a protective stop loss order under every trade. This is a proprietary ‘adaptive’ algo which is calculated as soon as the trade has been completed. We cannot stress this enough. In an automated system it is placed within milliseconds of the actual order. With our manual system we will be a bit slower, but nevertheless it is an essential component.
The range of complexity and functionality of algorithms is only limited by the cunning of the strategists and designers. Anything they can think up can be transformed into a trading algorithm. From the most basic (e.g. If trade price of XYZ touches $ nn.nn place a market order for 1000 shares) to the most advanced which would require several pages to describe even in outline.