Keith, Mike - many thanks. This is very helpful.
--- In [email protected], Keith McCombs <kmcco...@...> wrote:
>
> I've successfully used this kludge in the past.
> a = optimize("a", 10, 1, 20, 1);
> bminusa = optimize("bminusa", 10, 1, 20, 1);
> cminusb = optimize("cminusb", 10, 1, 20, 1);
> b = a + bminusa;
> c = b + cminusb;
>
> It would be so much nicer to be able to do:
> a = optimize("a", 10, 1, 20, 1);
> b = optimize("b", 20, a+1, 40, 1);
> c = optimize("c", 30, b+1, 60, 1(;
> But you can't because optimize() will not accept a variable parameter.
>
> -- Keith
>
> On 7/9/2010 17:46, Mike wrote:
> >
> > To get you on your way to the more important stuff, the quick and
> > dirty solution would be to just add the constraints to your Buy logic.
> >
> > e.g.
> >
> > Valid = A < B AND B < C AND ...;
> > Buy = ... AND Valid;
> >
> > Your optimization will blindly evaluate unnecessary combinations. But,
> > if the optimization time is not a factor, then this is a foolproof way
> > to get you to the next step without dickering around with clever coding.
> >
> > Otherwise, you can try to derive the later values as a function of the
> > earlier values and reduce the number of optimized variables.
> >
> > e.g.
> > b = 3 * a;
> >
> > Similarly, if you know that you will have enough bars in the
> > optimization period you could reduce the optimized variables to a
> > single index into predefined arrays.
> >
> > Regardless of whether or not you use the elements, predefined arrays
> > can have at most as many elements as there are bars under study. So,
> > if your range is 3 bars wide, you can only have 3 values in your a,b,c
> > arrays.
> >
> > e.g.
> > a[0] = 5; b[0] = 32; c[0] = 123;
> > ...
> > a[9] = 14; b[9] = 41; c[9] = 132;
> >
> > i = Optimize("index", 0, 0, 9, 1);
> >
> > varA = a[index];
> > varB = b[index];
> > varC = c[index];
> >
> > Or, use file operations fopen, fgets, fclose to read the values from
> > file based on a single optimized variable (e.g. index). This would
> > probably kill performance though.
> >
> > Mike
> >
> > --- In [email protected] <mailto:amibroker%40yahoogroups.com>,
> > "jh2222jh" <jh2222jh@> wrote:
> > >
> > > Suggestions on how to program the following?
> > >
> > > "a must be less than b, which must be less than c, etc."
> > >
> > > I'm optimizing a, b, c, and d, but the numerical value of each must
> > be from smallest to largest, otherwise the optimization is worthless.
> > Therefore it's either true or false, and only optimizes values of the
> > variables that maintain the "true" nature of the increasing value of
> > each variable.
> > >
> > > Thanks for any suggestions.
> > >
> > > J
> > >
> >
> >
>