Originally Posted By: Grat
So,

this is looks like the my idea. I'm publish two week before. Is better if optimize for the different days in week. In the monday is not optimal the same open hour like in the friday. But I'm not know, howto optimize for the each day. I get the error 40.

But i don't understant this:
Code:
int index = (int)(optimize(0, 0, 254, 1) / 254 * 299);



The optimize function computes an index into a lookup table. The lookup table stores the startHour and endHour combinations. There are 300 combinations per day. The optimize function picks an index into this lookup table. The expression is a bit complicated since it has to work around a limitation in the optimize function. It can only handle 255 steps, that is why it looks for a value between 0 and 254 and than scales that to [0, 299]. So not all entries in the lookup table can be picked but it is good enough.

If one would want to pick a different startHour/endHour depending on the weekday one possible solution for that would be to create one separate algorithm for each day f.i. by adding another parameter to the TradeIS() function and then adding more algos in the algo loop.