Wrote a Forex Bot just to see if it would work

I have written a Forex bot to trade on the 15 minute candles. After doing a lot of statistical analysis etc… which I have posted about I decided to see if I could make it work for me. He has been running for a couple of weeks now and in that time he has been tweaked, in his current incarnation he has only been running for just over a day. Yesterday he started out $7 down then was $9 up and ended the day on breakeven so while it was not a great success it was also not a spectacular failure either. I have tried to give him every advantage possible and I am going to see if he makes a profit over the next several months.

Here is how he operates…
Every 24 hours (5:04pm Eastern Time) and also on startup he will grab the list of currencies from the broker and run some backtests on them. Each currency gets tested on a little over 30 different strategies for the past 500 candles (5 days at 15 minute candles) and the best strategy for that currency is stored for later. One a two processor machine the backtesting takes around 8 minutes or so for 68 currency pairs. So now that he has the strategy he will be using for each currency pair he waits until the close of a 15 minute candle then he starts looking. If he has 3 open trades he will stop looking as that is his limit otherwise he gets the list of currency pairs from the broker and looks back at how well they have done over the past weeks worth of trading. It sorts them based on profitability for the week with the most profitable at the top. Then it looks back at the last 24 hours of trading and any pair that has shown a loss he will discard for this run. He has a slight bias towards the “main pairs” (EUR, USD, GBP etc…) in that if two currency pairs are equal he will favour the one with the “popular” currencies. So now he has his list and the order he wants to trade in he does one more thing. He will drop out any currency pair that has a currency in an already open trade so that he does not open any trades with common currencies. So if he has “EUR/USD” open he will not look at any pair with EUR or USD in them. Going through the list from top to bottom he looks at a currency pair, gets the strategy that he stored for it during the backtesting and executes the strategy. If it says to open an order then he will open it adjusting for bid/ask spread. He repeats that process until he has 3 open trades or until he reaches the end of the list. Then he goes back to sleep again. One more thing he does is to close out any trade that has been open for more than 3 hours. He also closes out all trades just before 5pm Eastern so that he does not carry over to the next day.

I am going to be running this bot for several months as long as it shows promise of profits. I will let you know if it works.

Additional - He risks no more than 2% of the account or 20% of the margin (whichever is smaller) per trade and sizes the lot size accordingly.

this its too complicated just to earn profit in forex, if this is a probability game then a simple strategy should work fine. dozens of strats to have a break even day sucks

Fortunately he runs the back tests and selects the plans automatically so I do not have to do anything. I had an earlier version that just had one plan but it did not work so well. That is where all of the prioritising based on profit and excluding non-profit pairs came from.

Have you compared backtesting results using random strategy selection? I am not sure, if seelcting strategy based on snapshot is not a random is disguise :slight_smile:

I did some large statistical analysis of various strategies including a few completely random ones (certain percentage chance of opening a trade in a random direction). The random strategy had the same pattern to it as any other strategy with some winners and losers on different currencies. Its only difference was that it was never the most successful or least successful one. There is another thread on this…
Some Statistics on the Charts - Trading Discussion / Currencies - BabyPips.com Forex Trading Forum

The strategy selection could be random in disguise as you said but, unfortunately, it is the best way that I have of selecting one. I am trying to catch the “strategy of the moment” or “the one that is likely to work now”.

Your random comment awakened an interest in me so just for fun I copied the code and made another bot that uses a purely random strategy. He gets the currency pairs in a random order and then has a 50/50 chance of opening a random long or short trade with each currency. He still has a 3 currency limit and an exclusion for not trading the same currency in a pair twice. Lets see how he does.

Why are bots so popular?
How to control it at all?

It looks decent, you did a great job anyway, I hope this is useful to someone.

Risks are calculated correctly in general.
Of course, everything needs to be tested, this is the right approach.
The only pity is that, as a rule, such systems do not work very long.
The market is changing a little faster.

Bots are popular because they stick to the rules you set for them (no emotion) and because they can trade more often that you can. They are always on the markets and not doing their day job, getting coffee or sleeping.

I am hoping that the frequent automatic backtesting keeps his systems relevant and up to date with the market conditions.