Mike805, I programmed your idea (I think) and tried it out. For the price stream I used the most recent 1000 daily closes of the emini S&P futures contract ES. For the random numbers I generated UNIFORMLY DISTRIBUTED numbers between the observed min and the observed max of the price stream. The results were disappointing; no better than flipping coins; waaaay less than 66%:
999 predictions
501 correct
498 wrong
50.15 pct correct
Here's my Perl code
the code and the emini price data file are enclosed in the attached zip archive.
999 predictions
501 correct
498 wrong
50.15 pct correct
Here's my Perl code
Code:
use POSIX ;
# named constants
$PREDICT_LESS = 0;
$PREDICT_MORE = 1;
# read the historical price data (Format: Date,Price)
$themax = -100000.0 ;
$themin = 100000.0;
$nprices = 0;
while( $inputline = < STDIN > )
{
chop( $inputline ) ;
($ddate, $cclose) = split(',', $inputline );
$closeprice[$nprices] = $cclose;
$nprices++;
if($cclose > $themax) { $themax = $cclose; }
if($cclose < $themin) { $themin = $cclose; }
}
# generate random numbers and use them to predict whether
# tomorrow's price is greater or less than today's price
# make an arbitrary guess for the first day
$prediction = $PREDICT_LESS ;
$span = $themax - $themin ;
$numright = 0;
$numwrong = 0;
for($i=1; $i<$nprices; $i++) {
# evaluate the prediction made yesterday
if($prediction == $PREDICT_LESS) {
if($closeprice[$i] < $closeprice[$i-1]) { $numright++; }
else { $numwrong++; }
}
else { # yesterday we predicted MORE
if($closeprice[$i] > $closeprice[$i-1]) { $numright++; }
else { $numwrong++; }
}
# now make a prediction for tomorrow
# generate a UNIFORMLY DISTRIBUTED random number x
$x = rand() ;
$x = ($span * $x) + $themin ;
# compare today's closing price versus the random number
if($closeprice[$i] > $x) { $prediction = $PREDICT_LESS ; }
else { $prediction = $PREDICT_MORE ; }
}
# print the results
printf "%d predictions %d correct %d wrong %7.4f pct correct\n",
($numright + $numwrong), $numright, $numwrong, (100.0 * $numright / ($numright + $numwrong)) ;
# finished