[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: opt this



PureBytes Links

Trading Reference Links

Hello,

Here is a sample VBScript code that re-implements your code in
that way that you can optimize your projected band formula:

/* your original */
Graph0 = Min(L, Min(Ref(L,-1) +1* LinRegSlope(L, 14),
Min(Ref(L,-2) +2* LinRegSlope(L, 14),
Min(Ref(L,-3) +3* LinRegSlope(L, 14),
Min(Ref(L,-4) +4* LinRegSlope(L, 14),
Min(Ref(L,-5) +5* LinRegSlope(L, 14),
Min(Ref(L,-6) +6* LinRegSlope(L, 14),
Min(Ref(L,-7) +7* LinRegSlope(L, 14),
Min(Ref(L,-8) +8* LinRegSlope(L, 14),
Min(Ref(L,-9) +9* LinRegSlope(L, 14),
Min(Ref(L,-10) +10* LinRegSlope(L, 14),
Min(Ref(L,-11) +11* LinRegSlope(L, 14),
Min(Ref(L,-12) +12* LinRegSlope(L, 14),
Ref(L,-13) +13* LinRegSlope(L, 14))))))))))))));

/* VBScript re-implementation by TJ */

EnableScript("VBScript");


<%
Function CalcIt( Low, LinReg, Count )
Result = Low

For i = 0 To 2*Count - 1
Result( i ) = -1e10 ' empty Values for initial Count elements
Next 

For i = 2*Count To UBound( Low )

Minval = Low( i )

For j = 1 To Count -1

ThisVal = Low( i - j ) + j * LinReg( i )
If Minval > ThisVal Then Minval = ThisVal 

Next 
Result( i ) = Minval

Next 

CalcIt = Result

End Function
%>

param = 14; // now you can change this to say param = Optimize( "param", 14, 5, 40, 1 );

scr = GetScriptObject();
Graph1 = scr.CalcIt( Low, LinRegSlope( Low, param ), param );


//////////////
"Everything is possible"

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "spxer" <t.willett@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, April 27, 2002 5:40 PM
Subject: [amibroker] Re: opt this


> This is only part of the formula. It is for a 14 period indicator. As 
> you can see the lines of code will change for every parameter input. 
> This is known as projection bands by Mel Widner, it is included in 
> metastock. (coded: ProjBandBot(14) which makes it easy to optimize)
> 
> 
> 
> Min(L, Min(Ref(L,-1) +1* LinRegSlope(L, 14),
> Min(Ref(L,-2) +2* LinRegSlope(L, 14),
> Min(Ref(L,-3) +3* LinRegSlope(L, 14),
> Min(Ref(L,-4) +4* LinRegSlope(L, 14),
> Min(Ref(L,-5) +5* LinRegSlope(L, 14),
> Min(Ref(L,-6) +6* LinRegSlope(L, 14),
> Min(Ref(L,-7) +7* LinRegSlope(L, 14),
> Min(Ref(L,-8) +8* LinRegSlope(L, 14),
> Min(Ref(L,-9) +9* LinRegSlope(L, 14),
> Min(Ref(L,-10) +10* LinRegSlope(L, 14),
> Min(Ref(L,-11) +11* LinRegSlope(L, 14),
> Min(Ref(L,-12) +12* LinRegSlope(L, 14),
> Ref(L,-13) +13* LinRegSlope(L, 14))))))))))))));
> 
> 
> --- In amibroker@xxxx, "nenapacwanfr" <nenapacwanfr@xxxx> wrote:
> > write your code and inside
> > // write your needs 
> > it will be easier to help you
> > 
> > > Hi all. I am new to AB and I don't know how to proceed on this 
> > point. 
> > > I want to optimize an indicator in a system test. This indicator 
> > > requires a different length of code for each parameter setting. 
> > The 
> > > only way I know how to write it is as separate indicators. What 
> > can I 
> > > do to optimize? Thanks, Terry
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
>