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

[amibroker] Re: Inline Backtester Metrics



PureBytes Links

Trading Reference Links

Note that this is the raw trade signals.
It can be used to produce the key evaluation metrics (my term):

Win/Loss ratio
PayOffRatio

The GrowthFactor can be used for MoneyManagement applications e.g. 
the default eq curve is compounding but you could produce one for 
fixed eq investing as well.

If you want to calculate open equity then I think it can be done as 
well (probably you would use a latch to flag that you are in the 
trade and recalc the value).

As I said, the fun part is if you want to do sophisticated trade 
analysis and MM (you need to able 'write' the trade series to a 
persistant array without all the zeroes so that min/max and frequency 
dists can be applied).

brian_z


--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> Herman,
> 
> IBM PartI
> 
> I am not sure if this is along the lines that you are investigating.
> It might be a starting point.
> Sophisticated functions can be built from the concept.
> 
> Example of using single symbol equity function to back calculate 
the 
> trade series.
> 
> I used buy Tues(C) and sell Thurs(C) with one month of data to test 
> the code as I went along (this gave me unambiguous signals with 
only 
> one signal at a time - I believe you can use an eq flag to dump 
dual 
> signals for real life use).
> 
> Note: some weeks don't have Mons or Fris so I wanted to avoid no 
> signals, caused by short weeks, during testing
> 
> I used barindex() > 4 to cut out the first week in the month so 
that 
> I started with no signals for a few bars before the first buy.
> 
> I left the plot code in there but commented out (I plotted each 
line 
> to test the veracity of the code).
> 
> Note that when the trade series is used to recreate the eq curve 
(as 
> a cross check) it only matches on the exit bars for each trade.
> I tried it on 10 years of Yahoo data and the final eqs matched to 2 
> decimal places (rounded off).
> 
> //P_InLineEquity
> //code to reverse engineer the trade series from the equity curve
> //it is reversed at the end to check the accuracy of the method
> 
> InitialEq = 10000;//input required
> 
> SetOption("InitialEquity", InitialEq ); 
> 
> Buy = BarIndex() > 4 AND DayOfWeek() == 2;//use your own
> Sell = BarIndex() > 4 AND DayOfWeek() == 4;//use your own
> 
> BuyPrice = C;//use your own
> SellPrice = C;//use your own
> 
> Plot(Equity(),"Equity",5,1);
> 
> Entry = IIf(Equity() == Ref(Equity(),-1) AND Equity() != Ref(Equity
> (),1),1,0);
> 
> //Plot(Entry,"Entry",1,1);
> 
> Exit = IIf(Equity() != Ref(Equity(),-1) AND Equity() == Ref(Equity
> (),1),1,0);
> 
> //Plot(Exit,"Exit",2,1);
> 
> TradeSeries = IIf(Exit ==1,ValueWhen(Exit == 1, 
SellPrice,1)/ValueWhen
> (Entry == 1, BuyPrice,1),1);
> 
> //Plot(TradeSeries,"TradeSeries",1,1);
> 
> GF = 1;//GrowthFactor
> 
> for (i = 1; i < BarCount; i++)
> {
> GF[i] = GF[i-1] * TradeSeries[i];
> }
> 
> //codesters might be able to make the above loop better/prettier?
> //Plot(GF,"GrowthFactor",5,1);
> 
> 
> Plot(InitialEq * GF,"CalculatedEquity",1,1);
>



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

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
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/