Divide biggest MAE by current account balance
0 replies
Michael
3 years ago #268911
Hello all,
I want to show the biggest MAE in %. For this, the biggest MAE should be divided by the current account balance and mulitplied by 100. The code for biggest MAE is the following:
package SQ.Columns.Databanks;
import com.strategyquant.lib.L;
import com.strategyquant.lib.SettingsMap;
import com.strategyquant.tradinglib.DatabankColumn;
import com.strategyquant.tradinglib.Order;
import com.strategyquant.tradinglib.OrdersList;
import com.strategyquant.tradinglib.SQStats;
import com.strategyquant.tradinglib.StatsTypeCombination;
import com.strategyquant.tradinglib.ValueTypes;public class BiggestMAE extends DatabankColumn {
public BiggestMAE() {
super(L.t(“Biggest MAE”), DatabankColumn.Decimal2PL, ValueTypes.Minimize, 0, 0, 100);setWidth(70);
setTooltip(L.t(“Biggest MAE – is the worst Maximum Adverse Excursion of all trades”));
}//————————————————————————
@Override
public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception {
double worstMAE = -Double.MAX_VALUE;for(int i = 0; i<ordersList.size(); i++) {
Order order = ordersList.get(i);if(order.MAE > worstMAE) {
worstMAE = order.MAE;
}
}return -1*worstMAE;
}}
Can someone help me in finding the current account balance of the trade and divide the variable worstMAE by it? I think the function AccountBalance from the class Order should suffice, but I don’t get it to work.