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

Re: [amibroker] What's wrong with my formula (trouble with custombacktest)



PureBytes Links

Trading Reference Links

First of all Louis, thanks for your initial question. Because of the reactions I have got on my email to you from Graham and Dingo, I could make some important corrections in my AmiBroker thinking. There are things that just don't work when using AFL's. I should have know better ... For the rest, please see email from Dingo ...
 
Regards, Ton.
 
----- Original Message -----
Sent: Saturday, March 22, 2008 10:49 PM
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

I am sorry, but I don't understand anything about what you're saying about .abs, COM, or stuff like that.  All I want to do is use the custom backtest to change my positionsize and for some reason it does not work.

Is there a step-by-step way to be sure I do it right?

Thanks,

Louis

2008/3/22, dingo <dingo@xxxxxxxxcom>:

Yes, the answer is "No".
 
BTW - you might want to check out "Batman" in one of the forum's file sections.  It might save you from having to write your own scripts.
 
d


From: amibroker@xxxxxxxxxps.com [mailto:amibroker@xxxxxxxxxps.com] On Behalf Of Ton Sieverding
Sent: Saturday, March 22, 2008 1:11 PM

To: amibroker@xxxxxxxxxps.com
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

Thanks Dingo. Yes that's what I have done now. I've made two small programs in
Visual Fox with following code :
 
AASettingsFile  = "C:\\Program Files\\AmiBroker\\Settings\\MySettings2.abs"
AB      = CreateObject("Broker.Application")
AA      = AB.Analysis
AA.LoadSettings(AASettingsFile)
 
First program with MySettings1.abs and second with MySettings2.abs. When looking
what happens in AB when I run these programs in VFP, I can see them switch the settings from MySettings1 to MySettings2. So this works fine.
 
But this also means that if I want to do things like this in AB, I am forced to work in a kind of batch environment. Correct ? Or is there a way to do this in AFL by calling these programs ? After what I have seen on the Forum the answer is no ...
 
Regards, Ton.
 
 
----- Original Message -----
From: dingo
Sent: Saturday, March 22, 2008 4:43 PM
Subject: RE: [amibroker] What's wrong with my formula (trouble with custombacktest)

The COM stuff is also useable by external scripts and that is when these particular functions are very useful. If you use an external script to control AB then you CAN load the settings file and then load the formula and then run the formula.  But the way AB is written this procedure does NOT work when you try to do the COM work inside an AFL formula.
 
d


From: amibroker@xxxxxxxxxps.com [mailto:amibroker@xxxxxxxxxps.com] On Behalf Of Ton Sieverding
Sent: Saturday, March 22, 2008 11:29 AM
To: amibroker@xxxxxxxxxps.com
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

Thanks Graham. Yes I thought I knew the 'AB Bible'. But it's telling me something else
than what AB is doing. And I just do not understand why. In the 'AmiBroker Object Model'
document LoadSettings is a method. Even the example in mentioned document says that
LoadSettings should set the Backtest environment to the loaded 'abs' file. So in
my humble opinion this should do what it says :
 
// Create AB object
AB =
CreateObject("Broker.Application");
// Retrieve AA object

AA = AB.Analysis;
// Load Mysettings1
AA.LoadSettings(
"C:\Program Files\AmiBroker\Settings\MySettings1.abs");
 
... setting the backtester environment to 'MySettings1.abs'. Unfortunately it's not doing that and I do not understand why not. If the manual tells me different things than what I am seeing something is wrong. It's me of course. But why ?
 
I know the discussion about this topic on the Forum. Running Loadsettings in an AFL is too late for the rest of the AFL code. So I should run it before the rest of the AFL. Let's say I am creating a separate AFL with just the above code and run the rest in another AFL after that. But even this seems to do nothing. The only thing I am getting the AA Window. That's all. I don't get it ...
 
Regards, Ton.
 
----- Original Message -----
From: Graham
Sent: Saturday, March 22, 2008 10:26 AM
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

The advanced backtest code is explained in the help files, see Amibroker Formula Language - Advanced Porfolio Backtester Interface.
 
Advanced code is for changing the backtest trades, or producing your own metrics after the main first pass (normal) backtest is completed. (note: custom backtest and advanced backtest refer to the same thing)

You have not shown any of this in the information provided. All you have shown are the front end settings which are used during the standard backtest, and are to be included in the main part of the AFL code, not in the custom backtest part.


--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com


On 22/03/2008, Ton Sieverding <ton.sieverding@scarlet.be> wrote:
I don't follow Graham and of course would like to be corrected. Are you telling me
that when starting my AFL with following instruction, the Backtester is not accepting
these settings when running the AFL ?
 
AA.LoadSettings("MySettings.abs");
 
If the Backtester is not following this instruction what than is the purpose of the
SAVE and LOAD feature in AA ? I have the feeling that I can save more setting
details by using the AA Settings screen than by loading the underneath mentioned
Settings.AFL. In other words, I my opinion there are more settings in de AA Settings
than I will find in the Setoption instruction ... And it's a hell of a lot easier to make an
ABS file than and Settings.AFL ...
 
Regards, Ton.

----- Original Message -----

From: Graham
Sent: Friday, March 21, 2008 9:57 PM
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

These are not custom (advanced) backtest codes, just the options for backtesting, and do not belong in the advanced file. They will not be read until after the backtest has been completed and is ready for changing in the cbt.
If you want these standard for all backtesting, then just use #Include function, not
#include  "C:\Program Files\Amibroker1\Formulas\Custom\custom_backtest.afl";
--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com

On 22/03/2008, Ton Sieverding <ton.sieverding@scarlet.be> wrote:
Louis please go to the 'Automatic Analysis' Tool and open the Settings. Modify all values according to want you want to see. Then SAVE everything in an ABS file that you can open in the beginning of your AFL. That's all ...
 
Regards, Ton.
 
----- Original Message -----
Sent: Friday, March 21, 2008 2:54 PM
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

Hi,

Ok let me try to explain again.

I have a file with

run = Optimize ("run", 1,1,1000,1);

SetOption("UseCustomBacktestProc", True );
SetCustomBacktestProc( "C:\\Program Files\\Amibroker1\\Formulas\\Custom\\custom_backtest.afl" );

SetOption("MaxOpenPositions", 5 );
SetOption("InitialEquity", 100000 );
SetOption("AllowPositionShrinking", True );
SetOption ("AllowSameBarExit", False);
SetOption ("ActivateStopsImmediately", False);
SetOption ("MinShares", 100);
SetOption ("MinPosValue", 5000);
SetOption ("PriceBoundChecking", True);
SetOption ("CommissionMode", 2);
SetOption ("CommissionAmount", 25);
SetOption ("AccountMargin", 100);
SetOption ("ReverseSignalForcesExit", True);
SetOption ("UsePrevBarEquityForPosSizing", True);
SetOption ("PortfolioReportMode",0 );
 

ShortTrades = ParamToggle("Short Trades?","Oui|Non",1);
Longtrades = ParamToggle("Long Trades?","Oui|Non",1);

PositionScore = Random();

buy=....;
sell=.....;
short=.... etc.


Then, in c:\\Program Files\\Amibroker1\\Formulas\\Custom\\custom_backtest.afl I have another file with


SetOption("MaxOpenPositions", 5 );
SetOption("InitialEquity", 100000 );
SetOption("AllowPositionShrinking", True );
SetOption ("AllowSameBarExit", False);
SetOption ("ActivateStopsImmediately", False);
SetOption ("MinShares", 100);
SetOption ("MinPosValue", 5000);
SetOption ("PriceBoundChecking", True);
SetOption ("CommissionMode", 2);
SetOption ("CommissionAmount", 25);
SetOption ("AccountMargin", 100);
SetOption ("ReverseSignalForcesExit", True);
SetOption ("UsePrevBarEquityForPosSizing", True);
SetOption ("PortfolioReportMode",0 );


and when I click "backtest" nothing happens if

SetOption("UseCustomBacktestProc", True );

but it works well if

SetOption("UseCustomBacktestProc", False);

but of course I'd prefer to use the custom backtest.

Also,  if I click the "use custom backtest" in the AB interface and choose the first file or the second, still nothing happens if custombacktestproc is true.  It has to be false for results to show.

Can you help?

Thanks,

Louis




2008/3/21, Graham <kavemanperth@gmail.com>:

I do not understand what you mean by parameters. The custom file is for the advanced backtest coding that is read after the portfolio backtest run is complete to either change the backtest or report special custom metrics.
If all you want is input information for the afl, then use #include


--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com

On 21/03/2008, Louis Préfontaine <rockprog80@xxxxxxcom> wrote:
Hi Graham,

Yes I have the file setted as you said, but what exactly should I put in that file?  If I put only the parameters and no rule, is it ok?

Ton: I am not sure what is AA or ABS...

Louis

2008/3/19, Ton Sieverding <ton.sieverding@scarlet.be>:

Louis, why are you using all these SetOptions when AA has the ABS facility ? Create an ABS, load the ABS in your AFL with LoadSettings method and you've got what you want. What's wrong with that ?
 
Regards, Ton.
 
----- Original Message -----
Sent: Wednesday, March 19, 2008 3:54 AM
Subject: Re: [amibroker] What's wrong with my formula (trouble with custombacktest)

Hi,

I don't have 4.90, so setbacktestmode does not work...

I edited a new file with this inside:

run = Optimize ("run", 1,1,1000,1);

SetOption("UseCustomBacktestProc", True );

SetOption("MaxOpenPositions", 5 );
SetOption("InitialEquity", 100000 );
SetOption("AllowPositionShrinking", True );
SetOption ("AllowSameBarExit", False);
SetOption ("ActivateStopsImmediately", False);
SetOption ("MinShares", 100);
SetOption ("MinPosValue", 5000);
SetOption ("PriceBoundChecking", True);
SetOption ("CommissionMode", 2);
SetOption ("CommissionAmount", 25);
SetOption ("AccountMargin", 100);
SetOption ("ReverseSignalForcesExit", True);
SetOption ("UsePrevBarEquityForPosSizing", True);
SetOption ("PortfolioReportMode",0 );
 

ShortTrades = ParamToggle("Short Trades?","Oui|Non",1);
Longtrades = ParamToggle("Long Trades?","Oui|Non",1);

PositionScore = Random();

and saved it as custom_backtest.afl at the right place.  Then  I added this at the beginning of the file with my formula:

SetOption("UseCustomBacktestProc", True );
SetCustomBacktestProc( "C:\\Program Files\\Amibroker\\Formulas\\Custom\\custom_backtest.afl" );


I don't understand why it is not working...

Louis


2008/3/18, Graham <kavemanperth@gmail.com>:

If you set custombacktestproc as true , you must have a custom backtest code to read.

you could try the function SetBacktestMode


--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com 


On 19/03/2008, Louis Préfontaine <rockprog80@xxxxxxcom> wrote:
Hi,

My formula starts like this:

run = Optimize ("run", 1,1,1000,1);

SetOption("UseCustomBacktestProc", True );

SetOption("MaxOpenPositions", 5 );
SetOption("InitialEquity", 100000 );
SetOption("AllowPositionShrinking", True );
SetOption ("AllowSameBarExit", False);
SetOption ("ActivateStopsImmediately", False);
SetOption ("MinShares", 100);
SetOption ("MinPosValue", 5000);
SetOption ("PriceBoundChecking", True);
SetOption ("CommissionMode", 2);
SetOption ("CommissionAmount", 25);
SetOption ("AccountMargin", 100);
SetOption ("ReverseSignalForcesExit", True);
SetOption ("UsePrevBarEquityForPosSizing", True);
SetOption ("PortfolioReportMode",0 );
 

ShortTrades = ParamToggle("Short Trades?","Oui|Non",1);
Longtrades = ParamToggle("Long Trades?","Oui|Non",1);

PositionScore = Random();

buy=.................................
sell=.....
etc.

Is there something wrong with this, as when I click "backtest" I see no results.  When I change the custombacktestproc for "false" everything works well, but how do I do to get it my own way?  Cause I'd like to be able to be in more than one trade at a time.   And also, I think been in more than one trade at a time could make my Monte Carlo backtesting more reliable (am I right?).

Thanks,

Louis
















__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___