MATLAB: Maximize/minimize output of weighted inputs

curve fittingMATLABmaximizeminimizeoptimization

I am trying to find an efficient method to "optimize" a result given a set if inputs and weights e.g. a stock trading strategy. I can use brute force to test every possible combination of weights for the inputs, but the processing is intense and slow. I have heard of genetic algorithms, neural networks and optimisation but really don't know too much more about them. I am not trading the stock market myself, but using this as learning example.
My example "system": I have four numeric inputs (i) from "technical indicators" of the price time series data normalized [0, 1], I weight (w) each input [-1, 1] and then sum the values: Y = (w1*i1) + (w2*i2) + (w3*i3) + (w4*i4);
For "trading": If Y>0 then BUY, otherwise SELL. The result of this trading will yield a return R; the idea for now is to find what weights return the highest R. I also have other metrics which describe the "success" of the system that I would also like to test, such as maxmizing profit/loss, minimizing drawdown etc, but I'll start here for now.
If I set up the problem:
tic
for w1=-1:0.1:1
for w2=-1:0.1:1
for w3=-1:0.1:1
for w4=-1:0.1:1
% evaluate results of trading
% compare to previous results
% if "better" then store w1,w2,w3,w4 else discard result
end
end
end
end
toc
On my computer this processing will take about 8 hours; is there a better way? Of course, if I add more inputs, the scale of the problem and the processing time will become unmanageable.
Optimisation newbie, so please be gentle…

Best Answer

Depends a lot on what R as a function of w looks like. LINPROG might be appropriate if the dependence of R on w is linear.