StrategyQuant
Assistente de IA QAlgoCloudQuantAnalyzerQuantDataManager
Curso GratuitoEmpresa
BlogDocumentaçãoFórumFale conosco
BlogMarketplace
Entrar
Criar conta grátis

Produto

  • Preços e licenças
  • Aprender
  • Marketplace
  • Começar teste gratuito

Aviso legal

  • Termos de Serviço
  • Política de Privacidade
  • Cookies

Contato

[email protected]

Empresa

StrategyQuant s.r.o.

Korunní 2569/108, Vinohrady, 101 00 Praha 10, República Checa, UE

IČ: 04000498

DIČ: CZ04000498

Redes sociais

  • Aviso Legal | PROCESSAMENTO E PROTEÇÃO DE DADOS PESSOAIS

    O desempenho passado não é garantia de sucesso futuro. Todas as informações devem ser consideradas apenas para fins educativos

    ESTADOS UNIDOS Aviso legal exigido pelo Governo - A Commodity Futures Trading Commission informa: A negociação de futuros e opções apresenta grandes potenciais de recompensa, mas também grandes riscos potenciais. Deve estar ciente dos riscos e disposto a aceitá-los para investir nos mercados de futuros e opções. Não negoceie com dinheiro que não possa perder. Isto não constitui uma solicitação nem uma oferta para comprar/vender futuros, ações ou opções sobre os mesmos. Não está a ser feita qualquer declaração de que qualquer conta irá ou terá probabilidade de obter lucros ou perdas semelhantes aos abordados neste documento. O desempenho passado de qualquer sistema ou metodologia de negociação não é necessariamente indicativo de resultados futuros.

    REGRA 4.41 DA CFTC - OS RESULTADOS DE DESEMPENHO HIPOTÉTICOS OU SIMULADOS TÊM DETERMINADAS LIMITAÇÕES. AO CONTRÁRIO DE UM REGISTO DE DESEMPENHO REAL, OS RESULTADOS SIMULADOS NÃO REPRESENTAM A NEGOCIAÇÃO REAL. ALÉM DISSO, COMO AS ORDENS NÃO FORAM EXECUTADAS, OS RESULTADOS PODEM TER COMPENSADO O IMPACTO, SE HOUVER, DE DETERMINADOS FATORES DE MERCADO, COMO A FALTA DE LIQUIDEZ. OS PROGRAMAS DE NEGOCIAÇÃO SIMULADA EM GERAL TAMBÉM ESTÃO SUJEITOS AO FACTO DE SEREM CONCEBIDOS COM O BENEFÍCIO DE UMA ANÁLISE RETROSPETIVA. NÃO ESTÁ A SER FEITA QUALQUER DECLARAÇÃO DE QUE QUALQUER CONTA IRÁ OU TERÁ PROBABILIDADE DE OBTER LUCROS OU PERDAS SEMELHANTES AOS APRESENTADOS.

    NÃO ESTÁ A SER FEITA QUALQUER DECLARAÇÃO DE QUE QUALQUER CONTA IRÁ OU TERÁ PROBABILIDADE DE OBTER LUCROS OU PERDAS SEMELHANTES AOS ABORDADOS NESTE SITE. SE DECIDIR INVESTIR DINHEIRO REAL, TODAS AS DECISÕES DE NEGOCIAÇÃO NOS MERCADOS FINANCEIROS DEVEM SER DA SUA INTEIRA RESPONSABILIDADE.

    © StrategyQuant 2026

    Desenvolvido por Klaudie.ai

    Voltar ao marketplaceDIGITAL

    Maior MAE em múltiplas operações

    StrategyQuantPlugins
    Maior MAE em múltiplas operações

    Calcula a pior excursão adversa máxima combinada quando várias posições estão abertas ao mesmo tempo, ajudando você a quantificar drawdowns em estratégias de entrada em lote (basket).

    Maior MAE - útil para analisar estratégias com ordens únicas ou múltiplas.

    Múltiplas Ordens vs. Ordem Única

    É mais eficiente distribuir o risco entre uma cesta de ordens do que em uma única ordem. Múltiplas posições de entrada oferecem mais flexibilidade sem exigir um posicionamento preciso de entrada única.

    Ao abrir múltiplas ordens simultaneamente na mesma direção, calcule o MAE total de todas as posições abertas. Se as posições estiverem em direções opostas (hedging), subtraia o MFE das posições opostas do MAE maior para obter o MAE global.

    Quatro Snippets

    BiggestMAEallTrade - Maior MAE para um contrato, normalizado por contrato para obter resultados precisos mesmo se a estratégia aumentar o tamanho do contrato durante o backtest.

    package SQ.Columns.Databanks;
    import com.strategyquant.lib.L;
    import com.strategyquant.lib.SQUtils;
    import com.strategyquant.lib.SettingsMap;
    import com.strategyquant.tradinglib.*;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.*;
    import java.lang.*;  
    // Mode in France by Emmanuel Evrard for the StrategyQuantX Community :)
    public class BiggestMAEallTrade extends DatabankColumn 
    {
        public BiggestMAEallTrade() 
        {
            super(L.tsq("Biggest Multiple MAE"), DatabankColumn.Decimal2PL, ValueTypes.Minimize, 0, 0, 100);
            setWidth(140);
            setTooltip(L.tsq("Biggest Multiple MAE - is the worst Maximum Adverse Excursion of all trades open at once"));
        }
        //------------------------------------------------------------------------
        @Override
        public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception 
        {
            double worstMAE = -Double.MAX_VALUE;
            Date date = new Date();
            Date dateTemp = new Date();
            double Total1 = 0;
            double Size1 = 0;
            for(int i = 0; i<ordersList.size(); i++) 
            {
                Order order = ordersList.get(i);
                dateTemp = new Date(order.CloseTime);
                Size1 = order.Size;
                if (Size1 == 0) { Size1 = 0.01; }
                if (dateTemp.equals(date))
                {
                    Total1 += order.MAE;
                }
                else
                {
                    date = new Date(order.CloseTime);
                    Total1 = order.MAE;
                }
                if((Total1 / Size1)  > worstMAE) 
                {
                    worstMAE = (Total1/order.Size);
                }
            }
            return -1*worstMAE;
        }
    }
    

    BiggestMAEallTradePct - Maior MAE como porcentagem do saldo da conta. Mostra se a estratégia utiliza um risco adequado em relação à conta (por exemplo, comparando com a perda máxima diária de 5%).

    package SQ.Columns.Databanks;
    import com.strategyquant.lib.L;
    import com.strategyquant.lib.SQUtils;
    import com.strategyquant.lib.SettingsMap;
    import com.strategyquant.tradinglib.*;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.*;
    import java.lang.*;  
    // Mode in France by Emmanuel Evrard for the StrategyQuantX Community :)
    public class BiggestMAEallTradePct extends DatabankColumn 
    {
        public BiggestMAEallTradePct() 
        {
            super(L.tsq("Biggest Multiple MAE %"), DatabankColumn.Decimal2Pct, ValueTypes.Minimize, 0, 0, 100);
            setWidth(70);
            setTooltip(L.tsq("Biggest Multiple MAE % - is the worst Maximum Adverse Excursion of all trades open at once compared to AccountBalance"));
        }
        @Override
        public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception 
        {
            double worstMAE = -Double.MAX_VALUE;
            Date date = new Date();
            Date dateTemp = new Date();
            double Total1 = 0;
            double Total2 = 0;
            for(int i = 0; i<ordersList.size(); i++) 
            {
                Order order = ordersList.get(i);
                dateTemp = new Date(order.CloseTime);
                if (dateTemp.equals(date))
                {
                    Total1 += order.MAE;
                }
                else
                {
                    date = new Date(order.CloseTime);
                    Total1 = order.MAE;
                }
                Total2 = SQUtils.safeDivide(Total1, order.AccountBalance - order.PL) * 100.0;
                if(Total2  > worstMAE) 
                {
                    worstMAE = Total2;
                }
            }
            return -1*worstMAE;
        }
    }
    

    BiggestMAEallHedgingTrade e BiggestMAEallHedgingTradePct - Para posições com hedge em direções opostas. Utiliza o MAE maior e subtrai o MFE da direção oposta. Funciona quando operações opostas estão abertas durante o MAE maior.

    package SQ.Columns.Databanks;
    import com.strategyquant.lib.L;
    import com.strategyquant.lib.SQUtils;
    import com.strategyquant.lib.SettingsMap;
    import com.strategyquant.tradinglib.*;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.*;
    import java.lang.*;  
    // Mode in France by Emmanuel Evrard for the StrategyQuantX Community :)
    public class BiggestMAEallHedgingTrade extends DatabankColumn 
    {
        public BiggestMAEallHedgingTrade() 
        {
            super(L.tsq("Biggest Multiple Hedging MAE"), DatabankColumn.Decimal2PL, ValueTypes.Minimize, 0, 0, 100);
            setWidth(140);
            setTooltip(L.tsq("Biggest Multiple Hedging MAE - is the worst Maximum Adverse Excursion of all trades open at once"));
        }
        //------------------------------------------------------------------------
        @Override
        public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception 
        {
            double worstMAE1= -Double.MAX_VALUE;
            double worstMAE2 = -Double.MAX_VALUE;
            double BesttMFE1= -Double.MAX_VALUE;
            Date date = new Date();
            Date dateTemp = new Date();
            double Total1 = 0;
            double Size1 = 0;
            int direction = 0;
            for(int i = 0; i < ordersList.size(); i++) 
            {
                Order order = ordersList.get(i);
                dateTemp = new Date(order.CloseTime);
                Size1 = order.Size;
                direction=order.getDirection();
                if (direction == 1)     								// Bullish positions
                {
                    if (Size1 == 0) { Size1 = 0.01; }
                    if (dateTemp.equals(date))
                    {
                        Total1 += order.MAE;
                    }
                    else
                    {
                        date = new Date(order.CloseTime);
                        Total1 = order.MAE;
                    }
                    if((Total1 / Size1)  > worstMAE1) 
                    {
                        worstMAE1 = (Total1/order.Size);
                    }
                }
            }
            Total1 = 0;
            for(int i = 0; i < ordersList.size(); i++) 
            {
                Order order = ordersList.get(i);
                dateTemp = new Date(order.CloseTime);
                Size1 = order.Size;
                direction=order.getDirection();
                if (direction == -1)     								// Bearish positions
                {
                    if (Size1 == 0) { Size1 = 0.01; }
                    if (dateTemp.equals(date))
                    {
                        Total1 += order.MAE;
                    }
                    else
                    {
                        date = new Date(order.CloseTime);
                        Total1 = order.MAE;
                    }
                    if((Total1 / Size1)  > worstMAE2) 
                    {
                        worstMAE2 = (Total1/order.Size);
                    }
                }
            }
            if (worstMAE1 >= worstMAE2)
            {
                Total1 = 0;
                for(int i = 0; i < ordersList.size(); i++) 
                {
                    Order order = ordersList.get(i);
                    dateTemp = new Date(order.CloseTime);
                    Size1 = order.Size;
                    direction=order.getDirection();
                    if (direction == -1)     								// Bearish positions
                    {
                        if (Size1 == 0) { Size1 = 0.01; }
                        if (dateTemp.equals(date))
                        {
                            Total1 += order.MFE;
                        }
                        else
                        {
                            date = new Date(order.CloseTime);
                            Total1 = order.MFE;
                        }
                        if((Total1 / Size1)  > BesttMFE1) 
                        {
                            BesttMFE1 = (Total1/order.Size);
                        }
                    }
                }
                return -1*(worstMAE1 - BesttMFE1);
            }
            else if (worstMAE2 > worstMAE1)
            {
                Total1 = 0;
                for(int i = 0; i < ordersList.size(); i++) 
                {
                    Order order = ordersList.get(i);
                    dateTemp = new Date(order.CloseTime);
                    Size1 = order.Size;
                    direction=order.getDirection();
                    if (direction == 1)     								// Bullish positions
                    {
                        if (Size1 == 0) { Size1 = 0.01; }
                        if (dateTemp.equals(date))
                        {
                            Total1 += order.MFE;
                        }
                        else
                        {
                            date = new Date(order.CloseTime);
                            Total1 = order.MFE;
                        }
                        if((Total1 / Size1)  > BesttMFE1) 
                        {
                            BesttMFE1 = (Total1/order.Size);
                        }
                    }
                }
                return -1*(worstMAE2 - BesttMFE1);
            }
            return 0;
        }
    }
    
    package SQ.Columns.Databanks;
    import com.strategyquant.lib.L;
    import com.strategyquant.lib.SQUtils;
    import com.strategyquant.lib.SettingsMap;
    import com.strategyquant.tradinglib.*;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.*;
    import java.lang.*;  
    // Mode in France by Emmanuel Evrard for the StrategyQuantX Community :)
    public class BiggestMAEallHedgingTradePct extends DatabankColumn 
    {
        public BiggestMAEallHedgingTradePct() 
        {
            super(L.tsq("Biggest Multiple Hedging MAE %"), DatabankColumn.Decimal2Pct, ValueTypes.Minimize, 0, 0, 100);
            setWidth(100);
            setTooltip(L.tsq("Biggest Multiple Hedging MAE % - is the worst Maximum Adverse Excursion of all trades open at once compared to AccountBalance"));
        }
        @Override
        public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception 
        {
            double worstMAE1= -Double.MAX_VALUE;
            double worstMAE2 = -Double.MAX_VALUE;
            double BesttMFE1= -Double.MAX_VALUE;
            Date date = new Date();
            Date dateTemp = new Date();
            double Total1 = 0;
            double Total2 = 0;
            int direction = 0;
            for(int i = 0; i<ordersList.size(); i++) 
            {
                Order order = ordersList.get(i);
                dateTemp = new Date(order.CloseTime);
                direction=order.getDirection();
                if (direction == 1)      								// Bullish position
                {
                    if (dateTemp.equals(date))
                    {
                        Total1 += order.MAE;
                    }
                    else
                    {
                        date = new Date(order.CloseTime);
                        Total1 = order.MAE;
                    }
                    Total2 = SQUtils.safeDivide(Total1, order.AccountBalance - order.PL) * 100.0;
                    if(Total2  > worstMAE1) 
                    {
                        worstMAE1 = Total2;
                    }
                }
            }
            Total1 = 0;
            for(int i = 0; i<ordersList.size(); i++) 
            {
                Order order = ordersList.get(i);
                dateTemp = new Date(order.CloseTime);
                direction=order.getDirection();
                if (direction == -1)      								// Bearish position
                {
                    if (dateTemp.equals(date))
                    {
                        Total1 += order.MAE;
                    }
                    else
                    {
                        date = new Date(order.CloseTime);
                        Total1 = order.MAE;
                    }
                    Total2 = SQUtils.safeDivide(Total1, order.AccountBalance - order.PL) * 100.0;
                    if(Total2  > worstMAE2) 
                    {
                        worstMAE2 = Total2;
                    }
                }
            }
            if (worstMAE1 >= worstMAE2)
            {
                Total1 = 0;
                for(int i = 0; i<ordersList.size(); i++) 
                {
                    Order order = ordersList.get(i);
                    dateTemp = new Date(order.CloseTime);
                    direction=order.getDirection();
                    if (direction == -1)      								// Bearish position
                    {
                        if (dateTemp.equals(date))
                        {
                            Total1 += order.MFE;
                        }
                        else
                        {
                            date = new Date(order.CloseTime);
                            Total1 = order.MFE;
                        }
                        Total2 = SQUtils.safeDivide(Total1, order.AccountBalance - order.PL) * 100.0;
                        if(Total2  > BesttMFE1) 
                        {
                            BesttMFE1 = Total2;
                        }
                    }
                }
                return -1*(worstMAE1 - BesttMFE1);
            }
            else if (worstMAE2 > worstMAE1)
            {
                Total1 = 0;
                for(int i = 0; i<ordersList.size(); i++) 
                {
                    Order order = ordersList.get(i);
                    dateTemp = new Date(order.CloseTime);
                    direction=order.getDirection();
                    if (direction == 1)      								// Bullish position
                    {
                        if (dateTemp.equals(date))
                        {
                            Total1 += order.MFE;
                        }
                        else
                        {
                            date = new Date(order.CloseTime);
                            Total1 = order.MFE;
                        }
                        Total2 = SQUtils.safeDivide(Total1, order.AccountBalance - order.PL) * 100.0;
                        if(Total2  > BesttMFE1) 
                        {
                            BesttMFE1 = Total2;
                        }
                    }
                }
                return -1*(worstMAE2 - BesttMFE1);
            }
            return 0;
        }
    }
    
    O desempenho passado não é garantia de sucesso futuro. Todas as informações devem ser consideradas apenas para fins educacionais Isenção de responsabilidade dos ESTADOS UNIDOS exigida pelo Governo - A Commodity Futures Trading Commission informa: A negociação de futuros e opções oferece grandes recompensas potenciais, mas também grandes riscos potenciais. Você deve estar ciente dos riscos e disposto a aceitá-los para investir nos mercados de futuros e opções. Não opere com dinheiro que não possa perder. Isto não é uma solicitação nem uma oferta para comprar/vender futuros, ações ou opções sobre os mesmos. Nenhuma declaração está sendo feita de que qualquer conta obterá ou terá probabilidade de obter lucros ou perdas semelhantes aos discutidos neste documento. O desempenho passado de qualquer sistema ou metodologia de negociação não é necessariamente indicativo de resultados futuros. REGRA 4.41 DA CFTC - RESULTADOS DE DESEMPENHO HIPOTÉTICOS OU SIMULADOS TÊM CERTAS LIMITAÇÕES. AO CONTRÁRIO DE UM REGISTRO DE DESEMPENHO REAL, RESULTADOS SIMULADOS NÃO REPRESENTAM NEGOCIAÇÕES REAIS. ALÉM DISSO, COMO AS OPERAÇÕES NÃO FORAM EXECUTADAS, OS RESULTADOS PODEM TER COMPENSADO O IMPACTO, SE HOUVER, DE CERTOS FATORES DE MERCADO, COMO A FALTA DE LIQUIDEZ. PROGRAMAS DE NEGOCIAÇÃO SIMULADOS EM GERAL TAMBÉM ESTÃO SUJEITOS AO FATO DE SEREM PROJETADOS COM O BENEFÍCIO DA ANÁLISE RETROSPECTIVA. NENHUMA DECLARAÇÃO ESTÁ SENDO FEITA DE QUE QUALQUER CONTA OBTERÁ OU TERÁ PROBABILIDADE DE OBTER LUCROS OU PERDAS SEMELHANTES AOS MOSTRADOS. NENHUMA DECLARAÇÃO ESTÁ SENDO FEITA DE QUE QUALQUER CONTA OBTERÁ, OU TERÁ PROBABILIDADE DE OBTER, LUCROS OU PERDAS SEMELHANTES AOS DISCUTIDOS NESTE SITE. SE DECIDIR INVESTIR DINHEIRO REAL, TODAS AS DECISÕES DE NEGOCIAÇÃO NOS MERCADOS FINANCEIROS DEVEM SER EXCLUSIVAMENTE SUAS.
    Grátis

    Arquivos

    • Snippet-BiggestMAEonmultipletrades.sqm14 KBBloqueado

    O download é liberado após a compra ou com um plano ativo.

    Detalhes
    Versão1.0.0
    Publicado19 de outubro de 2026
    Última atualização2 de novembro de 2026
    AppSQ
    TypeSnippet
    AuthorEmmanuel
    App version145.3058
    Codebase categoryDatabank / Filter