How to make backtest of my portfolio

I would like to know How Can I do a backtest of muy portfolio in Amibroker?
Is there any way to create a CSV file of muy portfolio Movements?

Thanks,

Thanks Tomasz , but I want to make a backtest of my account to get all the reports ect…

How can i get a csv file from my account with all the information about my movements?

Best Regards

I have found this way to backtest a csv file.

http://www.amibroker.com/kb/2014/09/30/gen-backtest-from-a-file/

The problem is that I run the backtest selecting the new file create, where I have written the code. It start running the backtest through the 2.000 symnbols I haven in my database. In my file I have only three or four movements.

Can you help me?

@Josmidur dont you think that your statements are a bit vague ? Perhpas you could desribe in details what do you really want, post the code you want to run and then expect some response, instead of posting some random mumbo jumbo.

I attach my code :

file = "C:\\Archivos de Programa\\AmiBroker\\Formulas\\Custom\\20.- CARTERA\\Cartera-Acciones.csv"; // change this to real location of your data file
dt = DateTime();
//
// Initialize variables
Buy = Sell = possize = 0; 
//
fh = fopen( file, "r" );
//
if( fh )
 {
     while( ! feof( fh ) )
     {
         line = fgets( fh );
         // get the ticker symbol from the file
         sym = StrExtract( line, 3, ';' );
         // if ticker matches current symbol
         if ( Name() == sym )
         {
             // extract data from line of text
             trade = StrExtract( line, 2, ';' );
             trade_datetime = StrToDateTime( StrExtract( line, 2, ';' ) );
             price = StrToNum( StrExtract( line, 5,  ';' ) );
             shares = StrToNum( StrExtract( line, 4,  ';' ) );
             //
             if ( trade == "Buy" )
             {
                 newbuy = dt == trade_datetime;
                 Buy = Buy OR newbuy; // combine previous buy signals with new
                 BuyPrice = IIf( newbuy, price, BuyPrice );
                 possize = IIf( newbuy, shares, possize );
             }
             //
             if ( trade == "Sell" )
             {
                 newsell = dt == trade_datetime;
                 Sell = Sell OR newsell; // combine previous sell signals with new
                 SellPrice = IIf( newsell, price, SellPrice );
             }
         }
     }
     //
     fclose( fh );
 }
 else
 {
     Error("ERROR: file can not be open" );
 }
//
SetPositionSize( 10, spsShares ); ```

This is the format of the information of the file "Cartera-Acciones.csv" thant this code try to open. I go to Analysis Window , select the file I attach before and I run the backtest but nothing happen, there is no report, ect... I do not what happen . Can  you help me? 

Thanks


3;28/08/2017;Buy;BA0030_ESP;35000;1.85;64750;97.125;64847.13
4;28/08/2017;Buy;IN0347_ALE;3400;18.99;64566;96.849;64662.85
5;30/08/2017;Buy;IB0114_ESP;9500;6.83;64885;973.275;64982.33
7;08/09/2017;Buy;AA0001_HOL;1580;38;60040;90.06;60130.06
8;22/09/2017;Sell;IN0347_ALE;3400;20.885;71009;1.065.135;70902.49
9;22/09/2017;Sell;IB0114_ESP;9500;6.63;62985;944.775;62890.52
10;22/09/2017;Sell;BA0030_ESP;35000;1.72;60200;90.3;60109.7
11;22/09/2017;Sell;AA0001_HOL;1580;39.75;62805;942.075;62710.79

@Josmidur,

this line

trade_datetime = StrToDateTime( StrExtract( line, 2, ';' ) );

is incorrect. Instead of just copy&pasting formula(s) from knowledge base article(s) rather take a look at the content of your data file and check where date is actually placed (column index).

Also check whether you are comparing intraday datetime array to datetime fo file.

Why don’t you simply use one of several debugging methods instead of guessing and not seeing issues without them? See How do I debug my formula Then you wouldn’t be left in the dark and would not need to ask simple things all the time you can easily find out yourself pretty quickly.

Thanks @fxshrat, but I have corrected the index in the line you mention, but it does not work. Can you help me?

@Josmidur,

  1. Get from stooq.pl the prices for Apple.
  2. Put into csv file the below two lines
aapl,Buy,2006-03-13,8.4745,375
aapl,Sell,2006-03-14,8.6862,375
  1. Execute Tomasz’s code from ( from KB ) - run Scan
  2. If the scan runs correctly ( you have the two lines visible ) then most likely you have not sufficient funds in the Backtester Settings.

@teyano I have done what you told me but It does not work. I have no idea…Can you help me?

Did you perform the scan ? Note stooq tickers are with the sufix ‘.us’ - add to the ticker or to the .csv file.

@teyano I send you my two files https://www.dropbox.com/s/z49x6cpkzcj29mw/Archivo%20comprimido.zip?dl=0

I have taken into consideration that my database have the same ticker name than the tickers in the cdv file. But no results. Anyway what I try is to make a backtest of all my trades , contained in the csv file.

This is the link for downloading the files https://www.dropbox.com/s/z49x6cpkzcj29mw/Archivo%20comprimido.zip?dl=0

Thanks to @fxshrat the problem is already solved.

My problem was

wrong selected symbol in analysis and missing historical data