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 by Eldar Agalarov for Amibroker (AFL)

Copy & Paste Friendly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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();
}
Back