Let me qualify before somebody judges me. This line if(!(Factor > 1)) is hilarious because negative of (Factor > 1) is Factor <= 1. So it's funny AI wrote Factor <= 1 that way.

Other line: strlen(FileName)+3 > 1024. is hilarious too. Because it's not necessary anyway. it could be only strlen(FileName) > MAX_PATH or strlen(FileName) > PATHSIZE.

Also filtering out the out of order bars is not responsibility of the algo. It should instead set a panic flag and stop modifying data until data makes sense (in order again) and throw a warning that some out of order data has been met. You could also supply STRICT_ORDERING to make it fix them instead of just quitting it's job which is unrelated to reordering the file.

Another issue is the silly pointer mathematics. Why all of a sudden it did:
Code
                T6* Current = Candles+i;
		T6* Previous = Candles+i+1;

It literally just did:
Code
if(Candles[i].time < Candles[i+1].time)
few lines above. All of a sudden array indexing is worse than pointer mathematics.

And finally a note on the algorithms. Removing outliers is bad in this case. The better option is taking the averages of two adjacent points and replacing the outlier so data coherency is maintained.

Theres more to say but I think this is enough.

JCL, this is an obvious slip-up on your part. You trusted AI blindly on this one.

Edit: I looked at the algorithm again and it's not removing outlier. it's mulplying them by distance between high and low of the candle ahead of it. But why is doing this:
Code
        if(Price > Previous*Factor) return 1;
	if(Price < Previous/Factor) return -1;
. Previous/Factor is throwing me off. Is AI smarter than me on this one or is it a bug? The rest of the algo looks just as confusing to me. At any rate, taking average of two adjacent points would have did better in backtests.

Last edited by EvanTJ; 22 minutes ago.