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

RE: [amibroker] TradeIt



PureBytes Links

Trading Reference Links

dingo, thanks for the code.  As for the idea about using exploration
results instead of backtest results.....damn, you mean I have to do the
work all over again in hopes that this other approach will
work.....  :)  Good thing it is a rainy day and I can't go
bicycling this afternoon.  I'll need the extra time for more
coding.  Oh happy days...not
Cheers
Sid
At 01:23 PM 04/22/2003 -0400, you wrote:
Actually,
you can sorta do most of what you're after:
 
Rather than do a backtest do an
exploration. You'll need to experiment with it some so you can see when
you get the signals. For example if you have your settings at delay = 1
Open and you run an exploration then you get all buy/sell/short/cover
signals on the day they occur (as if delay = 0). This can be
"fixed" by manipulating in code the  trade delay and the
prices to be used to mimic the backtester.
 
Once you do that then the door
is open as to what you can include in the output:
 
I've been experimenting with
some of Fred's code:
Filter=1;
 
/*=== This section uses
Tonetti's Equity Calc To generate Stats  ===*/
 
BIR     
= IIf(Status("BarInRange") > 0, 1, 0);
 
BarEq    =
Equity(1);
CurEq    = Equity();
MaxEq    = Highest(CurEq);
LogEq    = log10(CurEq);
 
dBuy     =
Ref(  Buy,-1);
dSell    = Ref( Sell,-1);
dShort   = Ref(Short,-1);
dCover   = Ref(Cover,-1);
LongProfit = IIf(dSell,E - ValueWhen(dBuy,E),0);
ShortProfit = IIf(dCover,E-ValueWhen(dShort,E),0);
TotTrdes = Cum(dSell OR dCover);
WinningTrades = Cum((LongProfit > 0) OR (ShortProfit >0));
PctWinners = WinningTrades / TotTrdes;
 
CurDD    =
IIf(BIR, 100 * (MaxEq - CurEq) / MaxEq, 0);
MaxDD    = Highest(CurDD);
CumDD    = Cum(CurDD);
 
FirstBar = ValueWhen(ExRem(Buy
OR Short, 0), Cum(1));
LastBar  = LastValue(ValueWhen(Status("LastBarInRange")
> 0, Cum(1)));
TotBars  = LastValue(Cum(1));
BarNo    = ValueWhen(BIR > 0, Cum(1) - FirstBar +
1);
NoBars   = LastValue(BarNo);
 
Dates    =
DateNum();
Days     = ValueWhen(BIR > 0, IIf(Dates !=
Ref(Dates,-1), 1, 0));
TotDays  = Cum(Days);
BPD      = BarNo / TotDays;
 
CAR     
= ValueWhen(BIR > 0, 100 * ((CurEq / Ref(CurEq, -(BarNo - 1))) ^ (1 /
(BarNo / BPD / 252)) -1));
Ann      = ValueWhen(BIR > 0, 100 * ((CurEq /
Ref(CurEq, -(252 * BPD)) - 1)));
MAR      = ValueWhen(BIR > 0, CAR /
MaxDD);
UI       = ValueWhen(BIR > 0, sqrt(CumDD
/ BarNo));
UPI      = (CAR - 5.4) / UI;
TPI      = UPI / MaxDD;
 
mm      
= LastValue(LinRegSlope(Ref(LogEq, -(TotBars - LastBar)),
NoBars));
 
BarsCum  = ValueWhen(BIR
> 0, Cum(BarNo));
AvgBar   = LastValue(BarsCum) / NoBars;
SRDevSQ  = ValueWhen(BIR > 0, sqrt(Cum((BarNo - AvgBar) ^
2)));
ErrEq    = LastValue(StdErr(Ref(logEq, -(TotBars -
LastBar)), NoBars));
KRatio   = ValueWhen(BIR > 0, mm * SRDevSQ / ErrEq /
sqrt(NoBars));
 
TradeEq  = IIf(Sell, (BarEq
- ValueWhen(Buy, BarEq)) / ValueWhen(Buy, BarEq), 0) + IIf(Cover, (BarEq
- ValueWhen(Short, BarEq)) / ValueWhen (Short, BarEq), 0);
PosEq    = Cum(IIf(TradeEq > 0, TradeEq, 0));
NegEq    = Cum(IIf(TradeEq < 0, TradeEq, 0));
PosTrade = Cum(TradeEq > 0);
NegTrade = Cum(TradeEq < 0);
AvgPos   = PosEq / PosTrade;
AvgNeg   = NegEq / NegTrade;
PosPct   = PosTrade / (PosTrade + NegTrade);
Expect   = (1 + AvgPos / abs(AvgNeg)) * PosPct - 
1;
 
PF      
= CurEq/NoBars/MA(C,63);
 
/*=== This section adds columns
to the Exploration === */
 
AddColumn(Buy,"Buy",1.0);
AddColumn(Sell,"Sell",1.0);
AddColumn(Short,"Short",1.0);
AddColumn(Cover,"Cover",1.0);
AddColumn(O, "Open",1.2);
AddColumn(L, "Low",1.2);
AddColumn(H, "High",1.2);
AddColumn(C, "Close",1.2);
 
AddColumn(CurEq,"Equity",1.2);
AddColumn(Car, "Car",1.2);
AddColumn(Ann, "Ann%",1.2);
AddColumn(-CurDD,"CDD%",1.2);
AddColumn(-MaxDD,"MDD%",1.2);
AddColumn(MAR,"MAR",1.2);
AddColumn(UI, "UI",1.2);
AddColumn(UPI, "UPI",1.2);
AddColumn(TPI, "TPI",1.2);
AddColumn(Expect, "Expect",1.2);
AddColumn(KRatio, "KRatio",1.2);
AddColumn(100*PctWinners,"%Accur",1.2);
AddColumn(TotTrdes,"# Trdes",1.0);
AddColumn(PF,"PF",1.4);
 
/*
===================================
   the columns below are reserved for 
   Optimized signal levels. There
   are a total of 10 allowed. The 
   ones not used should have the
   word "Rsvd" as the col heading
=================================== */
AddColumn(SLevel,"SLevel",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);
AddColumn(0,"Rsvd",1.0);


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

From: Sidney Kaiser
[mailto:s9kaiser@xxxxxxxxxxx]


Sent: Tuesday, April 22, 2003 11:51 AM

To: amibroker@xxxxxxxxxxxxxxx

Cc: tj@xxxxxxxxx; com@xxxxxxx

Subject: Re: [amibroker] TradeIt

At 08:26 AM 04/19/2003 -0700, you wrote:

>While we wait for TJ to design and code some portfolio testing
capability

>for AB, has anyone tried some of the alternatives such as
TradeIt?

>

>Chris Kryza wrote TradeIt as a post processor for AIQ trades two
or three

>years ago and I used it a few times back then.  It accepts
trade data in

>CSV form so the thought occurred to me that it might be possible
to export

>AB backtest data and run TradeIt on that data.

>

>Before I spend a bunch of time trying to get it to work I would
like to

>know if someone has already looked at using TradeIt with AB trade


>data.  If so:

>

>1. did it work

>

>2. how difficult was it to adapt it

>

>3. were the results worth the effort involved

TradeIT  is not the worlds greatest portfolio trader, just an
available 

example that had possibilities for adaptation to AA output.

I dug into the adaptation issue some this weekend.  The output
from AA 

backtest can be rearranged to fit the input fields of TradeIT with
some 

help from an intermediate modification in Excel.  Unfortunately
there is 

one problem I have not been able to overcome.  There is no
information 

available from AA about price or equity movement between
trades.  This 

information is essential to creating a comprehensive report from


TradeIT.  (see TradeIT sample file for data input
fields)

I believe Fred Tonetti also mentioned this as serious deficiency in
one of 

his previous posts about the limitations of what he can calculate in
his 

expanded equity indicator.  You can't get there from here with
the present 

information coming out of AA.

As a side issue, I am reminded once again that I want to be able to
specify 

additional calculated columns in AA backtest display.  For
example, I might 

want to include MAR = CAR/MDD as a column or ( more complicated )
include 

data on max or min excursions of various data columns as part of my
AA 

results. It would also be helpful to be able to specify which data
columns 

are displayed and specify their display order.  Finally, being
able to 

optimize based on something like UPI or MAR would save me time and
improve 

optimization results by offering alternatives to only optimizing on
max profit.

Comments?

Sid

At this point I guess the best we can hope for is to get TJ to read
the 

TradeIT documentation for ideas on features to incorporate in his
proposed 

portfolio tester. 


Send BUG REPORTS to bugs@xxxxxxxxxxxxx

Send SUGGESTIONS to suggest@xxxxxxxxxxxxx

-----------------------------------------

Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx


(Web page:
http://groups.yahoo.com/group/amiquote/messages/)

--------------------------------------------

Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html


Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


Yahoo! Groups Sponsor 
 

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.471 / Virus Database: 269 - Release Date: 04/10/2003



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).

Attachment: Description: ""

Attachment: Description: "Version: 6.0.471 / Virus Database: 269 - Release Date: 04/10/2003"