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

    Fechar todas as posições exceto uma

    StrategyQuantPlugins
    Fechar todas as posições exceto uma

    Feche todas as posições abertas que correspondam aos critérios especificados, mantendo uma protegida por magic number. Útil para gestão seletiva de carteira e controlo de risco em estratégias de negociação com múltiplas posições.

    Fechar todas as posições exceto uma: o “Magic Number Excluded” selecionado

    package SQ.Blocks.Order.Close;
    import SQ.Functions.OrderFunctions;
    import SQ.Internal.ActionBlock;
    import com.strategyquant.lib.*;
    import com.strategyquant.datalib.*;
    import com.strategyquant.tradinglib.*;
    // Modified in France by Emmanuel Evrard for the StrategyQuantX Community :)
    @BuildingBlock(returnType = ReturnTypes.Action)
    @Help("Close All positions except one")
    @SortOrder(600)																			// In AlgoWizard, this is a dropbox position (400 or 500 or 600 etc.) of this function in the menu of "Add New Condition", you may have to adjust it depending on the function already installed on the same dropbox. 
    @IgnoreInBuilder
    @NotSupportedFor(engines="EL")
    public class CloseAllPositionsExcept extends ActionBlock 
    {
        @Parameter(defaultValue="Current", category="Order identification", showIfDefault=false, allowAny=true)
        public String Symbol;
        @Parameter(defaultValue="1", category="Order identification", showIfDefault=false)
        @Editor(type=Editors.Selection, values="Long=1,Short=-1,Any=0")
        public int Direction;
        @Parameter(defaultValue="MagicNumber", category="Order identification", showIfDefault=false)
        @Help("Magic number that can identify the order.")
        @Editor(type=Editors.SelectionVariablesWithAny)
        public int MagicNumber;
        @Parameter(defaultValue="MagicNumber", category="Order identification", showIfDefault=false)
        @Help("MagicNumber of the Excluded order, this order will not be closed")
        @Editor(type=Editors.SelectionVariables)
        public int MagicNumberExcluded;
        //@Parameter(defaultValue="", category="Order identification", showIfDefault=false)
        //@Help("Comment can be also used to identify the order. In case of Comment, order matches if the order comments contains the text specified here.")
        public String Comment;
        //------------------------------------------------------------------------
        //------------------------------------------------------------------------
        //------------------------------------------------------------------------
        public CloseAllPositionsExcept() 
        {
        }
        //------------------------------------------------------------------------
        @Override
        public void OnAction() throws TradingException 
        {
            int total = Strategy.Trader.getOpenOrdersCount(false);
            for(int i=total-1; i>=0; i--) 
            {
                ILiveOrder order = Strategy.Trader.getOpenOrder(i, false);
                if(OrderFunctions.identify(order, Strategy, Symbol, Direction, MagicNumber, Comment)) 
                {
                    if (order.getMagicNumber() != MagicNumberExcluded)	
                    {
                        order.setExitIndex((byte) -1);
                        order.Close(OrderCloseTypes.ExitSignal);
                    }
                }			
            }
        }
    }
    
    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-CloseAllpositionsexceptone.sqm4 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ção22 de outubro de 2026
    AppSQ
    TypeSnippet
    AuthorEmmanuel
    App version145.3058
    Codebase categoryOrder