Automated Back and Forward Testing with Agents CLI





If you are here, you wanted to see what I actually wrote myself. Behind the work I posted done by the AI's as they become ubiquitous. I wanted to write and share my work as I have built up what is my modern backtesting infrastructure. None of this is financial advice and quite frankly Im pretty sure if you listened to me instead of buying the index you would have lost money for sure. Disclaimer: Yes I am aware that I could have built my own backtesting engine in python and prompted to build in a way to avoid look ahead bias that is perhaps my next level, but I deemed that too hard for now and I wanted to do this passion project with docker.

The Infrastructure:

Currently all of this lives on my Macbook Pro which is my daily driver and takes up a bit of space about 100 gigabytes. You can see my CPU usage going through the roof. These are virtual application being run on my computer. Essentially you can consider them as headless processes doing some stuff. They are applications Im very familiar with and have spent the best part of like 7 years working with. This is here because this is the core. This software is what lets the agent interact with the MetaEditor and Terminal really well. I used the agents to wire it up. The local agent was really helpful. I have tried to prompt and chat with the regular LLMs so it could give me code that created all the containers using docker commands but it keep failing. The terminal instance of claude set this up this is what was the hardest part for me.

Article content
Docker Containers

The software I am running is MetaTrader5. Now while I have seen some institutions using it in the backend. It is mostly giving access to CFD brokers giving retail money access to things like 1:1000 leverage. See my real Togolese Trading Account. Exness.com being another famous provider of these products in Africa and Togo.

Article content
Look at this Leverage I can get gonna Blow up 500x Faster with this
Article content
Normal MT5, you can do buys and sells by clicking on the charts. its a terminal for trading.

In the United States only Trading.com and StoneX.com will provide you this platform to trade Spot FX and Futures Respectively. Now below you can see the strategy tester and the tool book highlighted. The tool allows you to do back test of single strategies, and indicators, you can even do really cool visualizations I have been seriously using this since 2021. Mainly to test and trade a time range breakout strategy.

Article content
Metatrader5 Strategy Tester
Article content
Can choose your data range, Data model 1m OHLC vs Tick Data
Article content
Pick inputs for this specific strategy

To work with the Strategy tester naturally we need strategies, and they are written and compiled here in MQL5 metaquotes proprietary language its really C++ with extra steps. Now if MT5 allowed you to use a makefile and a normal gcc compiler then it would be amazing and we would compile and check the logs that way. No you can only compile the strategies through the IDE so we need this process open and all our code needs to come through here. It was automated The black bar you see below is due to the GUI being broken and the MCP server just calls xdottool functions to use the keyboard and mouse so fast it bugs the GUI.

Article content
MetaEditor/IDE

I use to go through this process myself, run strategy see report, analyze the deals. Its not gonna make money, lets try the variants, nope. Ok all dead lets go somewhere else. This was fine but it took so long. Because I actually had to extract the deals and run scripts on that data to see if we are overfit, or if profit is clustered and I could make the calculation scripts but extracting and cleaning the data, and then having it in a easy to interact with and display format was hard. Im not a good programmer and Im probably the worst dashboard maker in human history. I really wished back then when I myself was actively testing strategies and reading about/discovering new metrics what if I could get ChatGPT to do this and like discover more stuff then I can come in and be another judge of wether its good or bad.

Today we have the glorious invention of Open claw and the power of the MCP server. So I finally was able to wire it up and here it is.

Article content
Looks so Underwhelming but does so much.

What does this actually mean for me and my research pipeline. It means I can stop struggling with coding errors. I can also learn what does not work so much faster. I can analyze what works and see why it does work, and the AI is the one more focused on what failed us.

Article content
Much Cooler

Finally, this is mainly a tool for me. I tend to know what I am testing but I work all over the place. I really wanted to get some feedback from good friend Devin Miles so I added this dashboard. Its tied to MCP processes for actually running the Test. I built the Dashboard you see below to complement the testing infrastructure and visualize more accurately what is happening under the hood. The deal level data was a really big thing for me an having it in here gives us a lot more agency. And allows use to do like KS test, and do MCs in this case here we are using autocorrelated FX data so its in 5 day boot strap blocks. Here we run one continuous position sized differently based on a weighted forecast based on other indicators.

Article content
this looks Not bad
Article content
But it is

If you care about my actual findings and not the process. Read the Initial Report

thanks for the gems, sir!

Like
Reply

To view or add a comment, sign in

Others also viewed

Explore content categories