Waldemar,

In order to backtest or optimize, you need to add a Buy and Sell command min 
your .afl file, something like, e.g.:


Buy = ROC(C,2)>3
Sell = ROC(C,2)<-3

where ROC(C,2) is the rate of change in percentage for the close price from the 
last 2 days -- use this for end-of-day (EOD) trading.  If you are using 
intraday, then just use ROC(2) for the last 2 bars.  

Backtesting and Optimization require both a Buy and Sell command in the .afl 
file.  Optimize requires use of "Optimize(...)" instead of "Param(...)" and you 
have to add an additional parameter to optimize. 


For example, look at the "MACD Optimize" example found in the help file:

Paste the code below in a new file called "Optimize_MACD.afl", load any chart, 
then insert this file from the left "Charts" panel


-start code------------------------------------

/* MACD (12,26,9 - 5,34,5 <==> by default - by Bill Williams */
/* variable = optimize( "Description", default, min, max, step ) */

fa = Optimize( "MACD Fast", 5, 5, 12, 1 );
sa = Optimize("MACD Slow", 34, 26, 34, 1 );
sig = Optimize( "Signal average", 5, 5, 9, 1 );

Buy = Cross( MACD( fa, sa ) , Signal( fa, sa, sig ) );
Sell = Cross( Signal( fa, sa, sig ), MACD( fa, sa ) );

-end code--------------------------------------

If you want to look at new optimization engines that are better than a grid 
search, add 

OptimizerSetEngine( "cmae" )  

to the beginning of the file.  Also, other options for the optimization engine 
are: 

Standard Particle Swarm Optimizer ("spso") 
Tribes (improved PSO) ("trib") 
Covariance Matrix Adaptation Evolutionary Strategy ("cmae") 
 
SPSO and PSO are very good, but I have found slightly better results for CMSA 
when doing function approximation and classification -- which are closer to 
results of gradient-based back-propagation 3-layer neural networks (MLPs).  
MLPs tend to do better than CMSA and PSO.  Original authors of CMSA also have 
stated clearly that they never expected CMSA to perform better then a 3-layer 
MLP.  






--- In [email protected], "Waldemar Rooijer" <walde...@...> wrote:
>
> Got but what I like to do is to backtest my formula based on the chances in
> eh nasdaq or DOW value chances, so the plot won't help me with the backtest
> purpose. Maybe I need to use another function to get the ^DJI value?
> 
>  
> 
> Waldemar Rooijer
> IT Solutions N.V.
> 
> Dr. M.J. Hugenholzweg 35
> Curacao, Netherlands Antilles
> Phone: (5999)-4613345
> 
> Cell:     (5999)-5624902
> Fax:     (5999)-4613346
> 
>  
> 
> From: [email protected] [mailto:[email protected]] On Behalf
> Of wavemechanic
> Sent: Monday, May 03, 2010 12:02 PM
> To: [email protected]
> Subject: Re: [amibroker] Slow of the close of ^DJI
> 
>  
> 
>   
> 
> The formula that you used will not by itself show you a value which.  To see
> the value you have to display it, for example, in a chart using the code
> below. You can see the value for any date in the title by clicking the plot
> at that date:
> 
>  
> 
> If you have ^DJI loaded then chart 
> 
>  
> 
> Plot( ROC( C, 2 ), "ROC(2)", colorRed );
> 
>  
> 
> or if you have another symbol loaded then chart
> 
>  
> 
> Plot( ROC( Foreign( "^DJI", "Close" ), 2 ), "ForROC(2)", colorWhite );
> 
>  
> 
> ----- Original Message ----- 
> 
> From: Waldemar Rooijer <mailto:walde...@...>  
> 
> To: [email protected] 
> 
> Sent: May 03, 2010 11:16 AM
> 
> Subject: RE: [amibroker] Slow of the close of ^DJI
> 
>  
> 
> Wavemechanic you mean I can use somethink like;
> 
>  
> 
> Wdji1 = Foreign(^DJI, "Close") and then Wdji2 = ROC(Wdji,2)
> 
>  
> 
> When I try that I don'r get any value listed for Wdji2. I don'r receive
> error in the code though
> 
>  
> 
>  
> 
> Waldemar Rooijer
> IT Solutions N.V.
> 
> Dr. M.J. Hugenholzweg 35
> Curacao, Netherlands Antilles
> Phone: (5999)-4613345
> 
> Cell:     (5999)-5624902
> Fax:     (5999)-4613346
> 
>  
> 
> From: [email protected] [mailto:[email protected]] On Behalf
> Of wavemechanic
> Sent: Monday, May 03, 2010 10:42 AM
> To: [email protected]
> Subject: Re: [amibroker] Slow of the close of ^DJI
> 
>  
> 
>   
> 
> Take a look at ROC()
> 
> ----- Original Message ----- 
> 
> From: WaldemarRooijer <mailto:walde...@...>  
> 
> To: [email protected] 
> 
> Sent: May 03, 2010 10:24 AM
> 
> Subject: [amibroker] Slow of the close of ^DJI
> 
>  
> 
> Dear members,
> 
> I am learning the AFL language for a few weeks and one issue I still could
> not figure out yet is how can I get the 2 day slope (ore maybe just %change)
> of ^DJI close.
> 
> Any help is appreciated
> 
> 
> 
> ------------------------------------
> 
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
> 
> TO GET TECHNICAL SUPPORT send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> Yahoo! Groups Links
>


Reply via email to