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

[amibroker] Work in Progress - Tradesim - Universal text Trade Database Version 1.1



PureBytes Links

Trading Reference Links

Just an update, of the 3 issues I posted earlier, I have managed to resolve issue 2, which was the date format, following an example of code posted by Stephane Carrasset.  Tradesim will now load successfully the file produced just by double clicking the file. Note that you must change your regional date settings to the format, YYYY/MM/DD. Cheers.

 

The two issues which remain are,

 

 

  1. Trade List

 

1.1    If I run the individual backtest, I only get the last symbols results.  Can the script be altered so all symbols are listed with their results ?

 

1.2    Portfolio backtest.  If we are unable to get the individual backtester working, what configuration would be required to get all possible trades using the portfolio backtester ?

 

 

  1. Initial stop value. 

 

I was going to leave this for a separate post,  but I feel like we are on a roll.  Is there also anyway to get the value of atr(period) at the first bar (or bar before) the entry signal ? This value is used for position sizing within Tradesim.

 

I would appreciate any help as I am a complete novice with Amibroker.  Here is the updated code,

 

 

 

/* Tradesim - Universal text Trade Database Version 1.1 - Work in Progress

 

Adapted from sample code in PBI Collected Documentation, 'How to create a Trade List By ShortFox'

 

Requirements:  To generate YYYYMMDD output, declare it in your regional settings

 

Revisions 1.1 Remove separators / from date format

 

Current Issues

- does NOT produce full trade list - all individual trades

- Initial stop value not yet used. Currently set to 0

 */

 

 

Buy = 0; Sell = 0; Short = 1; Cover = 0;

 

SetCustomBacktestProc("");

 

if ( Status( "action" ) == actionPortfolio )

{

    fh = fopen( "C:\\TestFile.trt", "w" );

 

    bo = GetBacktesterObject();

    bo.BackTest(); // High-Level backtest

 //   dt = DateTime();

 

    Initial_Stop = "0";

    // if Initial Stop data is not available then 0 placeholder should be used.

 

    for ( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )

    { // iterate through closed trades

        if ( trade.IsLong )

        {

            Long_Short = "L";

        }

        else

        {

            Long_Short = "S";

        }

 

// Revision 1.1 Fixup date format for Tradesim - remove date separators

EntryDate =  NumToStr(trade.EntryDateTime,formatDateTime);

entryyyyy=StrLeft(EntryDate,4);

entrymm=StrMid(EntryDate,5,2);

entrydd=StrRight(EntryDate,2);

TSEntryDate = entryyyyy+entrymm+entrydd;

 

ExitDate =  NumToStr(trade.ExitDateTime,formatDateTime);

Exityyyy=StrLeft(ExitDate,4);

Exitmm=StrMid(ExitDate,5,2);

Exitdd=StrRight(ExitDate,2);

TSExitDate = exityyyy+exitmm+exitdd;

 

 

 

        String =  trade.Symbol + " " + Long_Short + " " + TSEntryDate + " " + TSExitDate

        + " " + Initial_Stop + " " + trade.EntryPrice + " " + trade.ExitPrice;

       if ( fh )

          fputs( string + "\n", fh );

    }

 

    fclose( fh );

}

 

// Your trading system here...

 

Buy = C > EMA(C,20);

Sell = C < EMA(C,20);

 

 



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 other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS