While the code certainly works, the nested IIF do seem to slow down
optimizations considerably. For smaller opts, like in the given
example of only 4 ranges, it's not so bad. But for larger opts it will
be a problem.

Is there any strategy I could use to speed things up, or is this as
fast as AFL can go for this specific type of implementation?



--- In [email protected], "ozzyapeman" <zoopf...@...> wrote:
>
> Thanks, Graham! 
> 
> Wish I had a programmer-type brain.
> 
> Always amazes me how convoluted my thinking can be...
> 
> 
> 
> --- In [email protected], Graham <kavemanperth@> wrote:
> >
> > seems a complex way of doing things
> > try this
> > 
> > RangeTest = Optimize("RangeTest", 1, 1, 4, 1);
> > array = c;
> > Range = iif( array >1.3, 4, iif( array >1.2, 3, iif( array >1.1, 2,
> > iif( array >0, 1, 0 ))));
> > 
> > buy = range==rangetest;
> > sell=0;
> > applystop( stopTypeNBar, stopModeBars, 6, 0 );
> > 
> > 
> > this line > Sell = BarsSince(Buy) > 6; will not work very well because
> > buy can occur on consecutive bars and will re-initiate the barssince.
> > You need to add in exremspan statement to remove buy signals for the
> > n-bar period
> > 
> > 
> > -- 
> > Cheers
> > Graham Kav
> > AFL Writing Service
> > http://www.aflwriting.com
> > 
> > 
> > 
> >     Range1 = Array > 0       AND Array <= 1.1000;
> > >         Range2 = Array > 1.1000  AND Array <= 1.2000;
> > >         Range3 = Array > 1.2000  AND Array <= 1.3000;
> > >         Range4 = Array > 1.3000;
> > 2009/1/17 ozzyapeman <zoopfree@>:
> > > Hello, hoping someone can point out the general flaw in logic
> here. Even
> > > though I've been working with AFL for six months now, array vs
> scalars can
> > > still be confusing. All I'm trying to do is pass an array to a
> function that
> > > tests it's range. The program  then sets a Buy according to that
> range. An
> > > optimization is  performed to find the "best" range for a given
> period.
> > >
> > > Of course this is not my actual trading system, but merely a test
> of concept
> > > for much a more complicated function.
> > >
> > > By definition, the Close price has to fall into one of the four
ranges
> > > defined in the function. I am using Forex, but any symbol will do,
> and would
> > > fall into one of the four ranges. Therefore, running the
> Optimization should
> > > generate some trades, as the Buy condition will be true
> eventually, as we
> > > cycle through the "RangeTest" variable for each bar. But no
trades are
> > > generated.
> > >
> > > Traces indicate that the Close array is not being cycled through.
> > >
> > > Shouldn't the following code work, without having to get into a
> Barcount
> > > loop? If not, where is the flaw? Any help much appreciated.
> > >
> > >
> > > RangeTest = Optimize("RangeTest", 1, 1, 4, 1);
> > >
> > >
> > >     function RangeFind(Array)
> > >     {
> > >         ActualRange = 0;
> > >
> > >         Range1 = Array > 0       AND Array <= 1.1000;
> > >         Range2 = Array > 1.1000  AND Array <= 1.2000;
> > >         Range3 = Array > 1.2000  AND Array <= 1.3000;
> > >         Range4 = Array > 1.3000;
> > >
> > >         for( n = 1; n <=4; n++)
> > >         {
> > >
> > >           RangeN = VarGet( "Range"+ NumToStr(n, 1.0,0) );
> > >
> > >           if (RangeN) ActualRange = n;
> > >
> > >         }
> > >
> > >       return ActualRange;
> > >     }
> > >
> > >
> > > Buy = RangeFind(Close) == RangeTest;
> > >
> > > Sell = BarsSince(Buy) > 6;
> > >
> >
>


Reply via email to