I'm creating a strategy that has random entry and a time stop of five periods. My problem is that % profitable generally becomes greater than 50% and I can't see why.
I've created a variable that isn't used in the code and then optimized the strategy retrieving 20 results. When I view all of the 20 results the average accuracy is consistently over 50% and I seldom get a single result below 50%. I get this problem when testing on 7000-8000 trades.
Any ideas?
Here's my code:
Random rnd = new Random();
protected int GetRandomInt(int min, int max)
{
return rnd.Next(min,max);
}
int myInt;
protected override void OnBarUpdate()
{
myInt = GetRandomInt(0, 2);
if(BarsSinceEntry() == 5)
{
ExitLong("", "");
ExitShort("", "");
}
if(myInt == 1 && Position.MarketPosition == MarketPosition.Flat)
{
EnterShort(10000, "");
}
if(myInt == 0 && Position.MarketPosition == MarketPosition.Flat)
{
EnterLong(10000, "");
}
}
Comment