StrategyQuant
Assistente IA QAlgoCloudQuantAnalyzerQuantDataManager
Corso gratuitoAzienda
BlogDocumentazioneForumContattaci
BlogMarketplace
Accedi
Crea un account gratuito

Prodotto

  • Prezzi e licenze
  • Impara
  • Marketplace
  • Inizia la prova gratuita

Note legali

  • Termini di servizio
  • Informativa sulla privacy
  • Cookie

Contatti

[email protected]

Azienda

StrategyQuant s.r.o.

Korunní 2569/108, Vinohrady, 101 00 Praha 10, Repubblica Ceca, UE

IČ: 04000498

P. IVA / DIČ: CZ04000498

Social

  • Note legali | TRATTAMENTO E PROTEZIONE DEI DATI PERSONALI

    I risultati passati non garantiscono successi futuri. Tutte le informazioni devono essere considerate esclusivamente a scopo didattico

    STATI UNITI Disclaimer richiesto dal Governo - La Commodity Futures Trading Commission informa: il trading su futures e opzioni comporta grandi ricompense potenziali, ma anche un grande rischio potenziale. È necessario essere consapevoli dei rischi ed essere disposti ad accettarli per poter investire nei mercati dei futures e delle opzioni. Non fare trading con denaro che non puoi permetterti di perdere. Questa non è né una sollecitazione né un'offerta per acquistare/vendere futures, azioni o opzioni su di essi. Non viene rilasciata alcuna dichiarazione che un qualsiasi conto conseguirà o con ogni probabilità conseguirà profitti o perdite simili a quelli discussi in questo documento. Le performance passate di qualsiasi sistema o metodologia di trading non sono necessariamente indicative dei risultati futuri.

    REGOLA CFTC 4.41 - I RISULTATI DI RENDIMENTO IPOTETICI O SIMULATI PRESENTANO DETERMINATI LIMITI. A DIFFERENZA DI UN REGISTRO DI RENDIMENTO REALE, I RISULTATI SIMULATI NON RAPPRESENTANO UN'ATTIVITÀ DI TRADING EFFETTIVA. INOLTRE, POICHÉ LE OPERAZIONI NON SONO STATE ESEGUITE, I RISULTATI POTREBBERO AVER COMPENSATO L'IMPATTO, SE PRESENTE, DI DETERMINATI FATTORI DI MERCATO, COME LA MANCANZA DI LIQUIDITÀ. I PROGRAMMI DI TRADING SIMULATI IN GENERALE SONO ANCHE SOGGETTI AL FATTO DI ESSERE PROGETTATI CON IL BENEFICIO DEL SENNO DI POI. NON VIENE RILASCIATA ALCUNA DICHIARAZIONE CHE UN QUALSIASI CONTO CONSEGUIRÀ O CON OGNI PROBABILITÀ CONSEGUIRÀ PROFITTI O PERDITE SIMILI A QUELLI MOSTRATI.

    NON VIENE RILASCIATA ALCUNA DICHIARAZIONE CHE UN QUALSIASI CONTO CONSEGUIRÀ, O CON OGNI PROBABILITÀ CONSEGUIRÀ, PROFITTI O PERDITE SIMILI A QUELLI DISCUSSI ALL'INTERNO DI QUESTO SITO. SE DECIDI DI INVESTIRE DENARO REALE, TUTTE LE DECISIONI DI TRADING NEI MERCATI FINANZIARI DEVONO ESSERE ESCLUSIVAMENTE TUE.

    © StrategyQuant 2026

    Offerto da Klaudie.ai

    Torna al marketplaceDIGITAL

    Imposta Stop Loss se il prezzo supera il limite (tranne uno)

    StrategyQuantPlugin
    Imposta Stop Loss se il prezzo supera il limite (tranne uno)

    Imposta automaticamente lo stop loss sugli ordini aperti quando il loro prezzo di apertura supera un limite specificato, escludendo un ordine designato. Ideale per gestire più posizioni senza chiudere immediatamente le operazioni in perdita.

    Imposta lo Stop Loss a un livello specificato se il prezzo di apertura (openPrice) dell'ordine è superiore (per posizione long) o inferiore (per posizione short) a un limite di prezzo.

    Se hai più posizioni aperte, eviterà di impostare lo stop loss sulle posizioni in perdita. Questo potrebbe chiudere immediatamente la posizione

    As we open several market orders, we may have to close all orders except one position   ("Magic Number Excluded")
    Here is the code :
    
    package SQ.Blocks.Order.Modify;
    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(name="(SIO) Set Stop Loss if Possible Except One", display="Set Stop Loss if Possible Except One", returnType = ReturnTypes.Action)
    @Help("Sets Stop Loss to a specified level if the openPrice order is above (for long position) or below (for short position) a price Limit except for one order : 'Magic Number Excluded'. If SL already exists it will be moved.")
    @SortOrder(500)																					// 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. 
    @CategoryOrder(200)
    @IgnoreInBuilder
    @NotSupportedFor(engines="EL")
    public class SetStopLossIfPossibleExceptOne extends ActionBlock 
    {
        @Parameter(defaultValue="Current", category="Order identification", showIfDefault=false, allowAny=true)
        public String Symbol;
        @Parameter(defaultValue="0", category="Order identification", showIfDefault=false)
        @Editor(type=Editors.Selection, values="Long=1,Short=-1")
        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="", 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;
        @Parameter(defaultValue="MagicNumber", category="Order identification", showIfDefault=false)
        @Help("MagicNumber of the Excluded order, this order will not be taken into account")
        @Editor(type=Editors.SelectionVariables)
        public int MagicNumberExcluded;
        @Parameter(category="Price Limit")
        @Help("Price limit of order, only Long Order with higher Open Price will be selected or only Short Order with lower Open price will be selected")
        @Editor(type=Editors.Formula, formulaName="RangeLevel")
        public IFormula PriceLimit;
        @Parameter(category="Stop Loss")
        @Editor(type=Editors.Formula, formulaName="RangeLevel")
        public IFormula StopLoss;
        //------------------------------------------------------------------------
        //------------------------------------------------------------------------
        //------------------------------------------------------------------------
        @Override
        public void OnAction() throws TradingException 
        {
            for(int i=0; i<Strategy.Trader.getOpenOrdersCount(false); i++) 
            {
                ILiveOrder order = Strategy.Trader.getOpenOrder(i, false);
                double openPrice = order.isNettingMode() ? order.getLastOpenPrice() : order.getOpenPrice();
                if(OrderFunctions.identify(order, Strategy, Symbol, Direction, MagicNumber, Comment)) 
                {
                    if (order.getMagicNumber() != MagicNumberExcluded)	
                    {
                        if (Direction != 1 && openPrice >= PriceLimit.evaluateFormula(Strategy, Symbol, openPrice, Direction))	
                        {
                            double sl = StopLoss.evaluateFormula(Strategy, Symbol, openPrice, Direction);
                            order.setSL(sl).Send();
                        }
                        if (Direction != -1 && openPrice <= PriceLimit.evaluateFormula(Strategy, Symbol, openPrice, Direction))	
                        {
                            double sl = StopLoss.evaluateFormula(Strategy, Symbol, openPrice, Direction);
                            order.setSL(sl).Send();
                        }
                    }
                }
            }
        }
    }
    
    I rendimenti passati non garantiscono successi futuri. Tutte le informazioni devono essere considerate esclusivamente a scopo didattico Disclaimer STATI UNITI richiesto dal Governo - La Commodity Futures Trading Commission informa: Il trading su futures e opzioni offre grandi opportunità di guadagno, ma comporta anche grandi rischi potenziali. È necessario essere consapevoli dei rischi ed essere disposti ad accettarli per poter investire nei mercati dei futures e delle opzioni. Non fare trading con denaro che non ci si può permettere di perdere. La presente comunicazione non costituisce né una sollecitazione né un'offerta di acquisto/vendita di futures, azioni o relative opzioni. Non viene rilasciata alcuna dichiarazione attestante che qualsiasi conto conseguirà o possa conseguire profitti o perdite simili a quelli descritti in questo documento. I rendimenti passati di qualsiasi sistema o metodologia di trading non sono necessariamente indicativi dei risultati futuri. REGOLA CFTC 4.41 - I RISULTATI DI RENDIMENTO IPOTETICI O SIMULATI PRESENTANO ALCUNI LIMITI. A DIFFERENZA DI UN REGISTRO DEI RENDIMENTI EFFETTIVI, I RISULTATI SIMULATI NON RAPPRESENTANO OPERAZIONI DI TRADING REALI. INOLTRE, POICHÉ LE OPERAZIONI NON SONO STATE EFFETTIVAMENTE ESEGUITE, I RISULTATI POTREBBERO NON AVERE RISENTITO DELL'IMPATTO, SE PRESENTE, DI DETERMINATI FATTORI DI MERCATO, COME LA MANCANZA DI LIQUIDITÀ. I PROGRAMMI DI TRADING SIMULATI IN GENERALE SONO ANCHE SOGGETTI AL FATTO DI ESSERE PROGETTATI CON IL BENEFICIO DEL SENNO DI POI. NON VIENE RILASCIATA ALCUNA DICHIARAZIONE ATTESTANTE CHE QUALSIASI CONTO CONSEGUIRÀ O POSSA CONSEGUIRE PROFITTI O PERDITE SIMILI A QUELLI MOSTRATI. NON VIENE RILASCIATA ALCUNA DICHIARAZIONE ATTESTANTE CHE QUALSIASI CONTO CONSEGUIRÀ, O POSSA CONSEGUIRE, PROFITTI O PERDITE SIMILI A QUELLI DESCRITTI ALL'INTERNO DI QUESTO SITO. QUALORA SI DECIDA DI INVESTIRE DENARO REALE, TUTTE LE DECISIONI DI TRADING NEI MERCATI FINANZIARI DEVONO ESSERE ESCLUSIVAMENTE PERSONALI.
    Gratis

    File

    • Snippet-SetStopLossifPriceExceedsLimitExceptOne.sqm5 KBBloccato

    Il download si sblocca dopo l’acquisto o con un livello attivo.

    Dettagli
    Versione1.0.0
    Pubblicato19 ottobre 2026
    Ultimo aggiornamento22 ottobre 2026
    AppSQ
    TypeSnippet
    AuthorEmmanuel
    App version145.3058
    Codebase categoryOrder