Question about back-testing bots that have a random trade element.
Question about back-testing bots that have a random trade element.
15 Mar 2016, 14:01
Hi all,
I have been experimenting with bots while I become familiar with their development, and one thing I have noticed when trialling some of the downloadable bots is that any bot that uses a random trade element (e.g. typically a Martingale bot) always seems to back-test with the same results. How can this be if the trades are meant to be random?
Surely, if nothing is changed on a back-test for one of these bots (i.e. all parameters are constant for each back-test), then the back-test results should vary depending on the random trades being performed by the bot? It seems, however, that the results are the same every single time. Am I doing something wrong? Is there some setting I should be using?
Thanks.
Replies
stevie.c
17 Mar 2016, 20:09
RE:
Thanks Spotware. When you say that only the direction of the opening position is random, do you mean to imply that only the direction of the very first opening position is random, and that no others are? Doesn't the following ensure that any new trade is random..?
private TradeType GetRandomTradeType() { return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell; }
Thanks.
@stevie.c
Jiri
17 Mar 2016, 23:53
Hello, if you want to execute random order each time, change following piece of code:
if (position.GrossProfit > 0) // if last closed position ended up in profit { ExecuteOrder(InitialQuantity, GetRandomTradeType()); // execute random trade type order } else // else { ExecuteOrder(position.Quantity * 2, position.TradeType); // execute same trade type order as last one with doubled quantity }
to this:
if (position.GrossProfit > 0) // if last closed position ended up in profit { ExecuteOrder(InitialQuantity, GetRandomTradeType()); // execute random trade type order } else // else { ExecuteOrder(position.Quantity * 2, GetRandomTradeType()); // execute random trade type order with doubled quantity }
I hope it helps. :)
@Jiri
Spotware
17 Mar 2016, 15:35
Dear Trader,
If you use the Sample Martingale cBot, without changing the initial source code the backtesting results should be slightly different. However, if you check the code you will notice that only the direction of the opening position is random. It is possible that many backtesting results could be almost identical if you use the same historical data.
@Spotware