Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

e-Ratio (Edge Ratio) Metric for Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
amibroker, metric, e-ratio

e-Ratio (Edge Ratio) metric for AmiBroker by Eldar Agalarov
e-Ratio is a metrics that measures the edge of a trading system component.

Similar Indicators / Formulas

Kavach Of Karna v2
Submitted by hbkwarez over 10 years ago
Advanced Elliott Waves
Submitted by MarcosEn about 13 years ago
3_6Day GuaiLiLv
Submitted by motorfly about 13 years ago
Williams Alligator System
Submitted by durgesh1712 about 13 years ago
Interactive Linear Regression Channel
Submitted by InternetWorm about 13 years ago
*Level Breakout system*
Submitted by Tinych about 13 years ago

Indicator / Formula

Copy & Paste Friendly
// e-Ratio implementation by Eldar Agalarov


if (Status("action") == actionPortfolio) {
	bo = GetBacktesterObject();
	bo.Backtest(True);

	stAll = bo.GetPerformanceStats(0);
	stLong = bo.GetPerformanceStats(1);
	stShort = bo.GetPerformanceStats(2);
	
	qtyProfitAll = stAll.GetValue("AllQty");
	qtyProfitLong = stLong.GetValue("AllQty");
	qtyProfitShort = stShort.GetValue("AllQty");	


	// e-Ratio
	avgMAEAll = avgMAELong = avgMAEShort = 0;
	avgMFEAll = avgMFELong = avgMFEShort = 0;
	barIndices = BarIndex();
	dateTimes = DateTime();
	for (trade = bo.GetFirstTrade(); !IsNull(trade); trade = bo.GetNextTrade()) {
		arrATR = Foreign("~ATR_" + trade.Symbol, "Close");
		tradeBarIndex = LastValue(ValueWhen(trade.EntryDateTime == dateTimes, barIndices));
		absMAE = trade.EntryPrice * trade.GetMAE() * 0.01;
		absMFE = trade.EntryPrice * trade.GetMFE() * 0.01;
		entryATR = arrATR[tradeBarIndex];
		normMAE = absMAE / entryATR;
		normMFE = absMFE / entryATR;
		avgMAEAll += normMAE;
		avgMFEAll += normMFE;
		if (trade.IsLong()) {
			avgMAELong += normMAE;
			avgMFELong += normMFE;
		} else {
			avgMAEShort += normMAE;
			avgMFEShort += normMFE;
		}
		trade.AddCustomMetric("MAE ($)", absMAE, 2);
		trade.AddCustomMetric("MFE ($)", absMFE, 2);
		trade.AddCustomMetric("Entry ATR", entryATR, 2);
	}
	avgMAEAll /= qtyProfitAll;
	avgMAELong /= qtyProfitLong;
	avgMAEShort /= qtyProfitShort;
	avgMFEAll /= qtyProfitAll;
	avgMFELong /= qtyProfitLong;
	avgMFEShort /= qtyProfitShort;
	eRatioAll = avgMFEAll / abs(avgMAEAll);
	eRatioLong = avgMFELong / abs(avgMAELong);
	eRatioShort = avgMFEShort / abs(avgMAEShort);
	bo.AddCustomMetric("e-Ratio", eRatioAll, eRatioLong, eRatioShort, 2);
	
	bo.ListTrades();
}

6 comments

1. parfumeur

Links to referenced discussion with explanations:

http://www.automated-trading-system.com/e-ratio-amibroker-code/
http://www.automated-trading-system.com/e-ratio-trading-edge/
http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/

2. kv_maligi

Hi parfumeur,

Thanks for information.

Any DLL are required.

I do not see any buy sell signals & also eratio graphs.

Can you add the above things. If exploration is added, it would be great help

Thanks
Viswanth

3. Ayuraveda

My Ami V 5.5 , but there is nothing on screen.
Could you please give the picture and DLL ?

Regards,
Ayuraveda

4. FilosofeM

@kv_maligi
There is no DLL required. This is AFL code. Just put the code to the new AFL file and in the AmiBroker Backtester Settings pick path to the current AFL file.
Next in the strategy code at the end put this code statement:

AddToComposite(avgTrueRange, “~ATR_” + Name(), “C”, atcFlagDeleteValues | atcFlagCompositeGroup | atcFlagEnableInBacktest);

This statement generates composite tickers with ATR data.

5. morgen

Was ist das?
A picture means 1000+ words!
No picture, no nothing!
No “Plot”, no nothing!

6. JaNa

God damn it, can’t you read??
It’s a metric for the backtester. It uses the Custom backest interface.

Read the freaggin manual!

And here is additional info besides the manual
http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/

Leave Comment

Please login here to leave a comment.

Back