Hello,
I started trading three years ago mainly as a hobby data analytics project, as I’m always messing with code.
I use automated trading, it works for me (with some worried moments), and I’ve seen some interest so thought I would outline my process for anyone interested. It could be total rubbish, so please take it with a pinch of salt.
I have two systems, both written mostly in Python and C, running on the AWS cloud to ensure good connectivity.
Here’s an outline of how it all works.
System 1:
-
Each Sunday it downloads the S30, M1, M5, M15, H1, H4, D price data from the previous week, adding it to a database of pricing data. This database keeps at least six months data.
-
For each Forex and CFD pair (about 93 in total) it will update a number of parameters such as:
- Recent volatility over x, y, z days (e.g 1, 3, 10 day volatility as a percentage of price)
- Return per pip at the current XR for a given margin (to understand the best value pairs to trade)
- Volatility and price movements at key times of the day (London, NYSE opening for example)
-
Using these updated values it will then go back over the past 6 months and simulate trading on an number of fairly simple strategies, such as SMA crosses, and adding various indicator values at the time of each trade (RSI, MACD etc.). It’s a computer, so it’s able to test a LOT of strategies - typically in the region of 1000 - 5000 different strategies, which are simply combinations of crosses and indicators.
-
It produces correlation matrix of loss / gain per trade and indicator value for each strategy. It notes the median levels of gain and loss - these are really important.
-
It selects which pairs to trade on the basis of recent volatility and return per pip for a given margin.
-
Finally it selects the strategy for each pair based on what came out of the analysis.
-
It will then trade the following week on this strategy.
-
When it trades, it uses an adaptive SL / TP, which is based on the statistics it has collected. Often it has a very deep SL - which goes against general advice - but more often than not the trade recovers into profit, even if it takes days. This can lead to some hairy moments.
-
Likewise it will dynamically adjust the TP based on analysis
Last week it made 38 trades, and 29 were successful. A successful trade usually gives about 70% of the return that an unsuccessful trade loses.
Where it struggles (or I do with the coding and general lack of knowledge) is in ranging markets. It (or I) struggle to correctly filter these out. That is a WIP.
System 2:
This is actually very simple, and a well known strategy.
- The program has with a window, say +/- 30 pips.
- Imagine the price crosses -30 pips
- The program will sell and set a mid point of the purchase price. Now the window is moved, and the TP is +30 pips, the SL -30 pips.
- If the price crosses the TP, the window is shifted gain. Now the TP is +60 pips and the SL 0 pips.
- This keeps going until the price reverses and crosses the SL.
- When it crosses the SL it will close the current open trade and make a trade in the opposite direction and repeat the process.
The overall effect is that it ‘walks’ up and down movements, and it’s very effective in volatility. See Oil last Thursday when it boomed 10$ in a few minutes…
Deciding the window:
- The program has a database of tick data for all pairs
- At the start of each week, it simulates all pairs using windows of different sizes, converging on the best setting per pair.
- The top X pairs from the analysis are picked to trade for the week based on success from the sim of the previous week.
- These are usually indexes!!!
- It out-performed system 1 last week, much to my disappointment, as it took about 30min to code (as opposed to weeks)
Anyway, above are my approaches to automating trading, as I’m utter rubbish by hand.
HTH someone who’s interested.