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

    Ordine a mercato multiplo

    StrategyQuantPlugin
    Ordine a mercato multiplo

    Apre simultaneamente più ordini a mercato con magic number sequenziali, consentendo la chiusura parziale delle posizioni a diversi target di profitto o stop loss. Ideale per strategie di scaling e per la gestione di livelli di rischio multipli.

    Snippet Multiple Orders at Market: invia più ordini contemporaneamente con magic number differenti.

    Nello screenshot, seleziona il numero di ordini e un magic number. Se selezioni 3 come numero di ordini e 1000 come magic number, verranno creati 3 ordini a mercato con i seguenti magic number: 1000, 1001 e 1002.

    Chiudi parzialmente alcuni ordini a mercato su un target di profitto, quindi chiudi gli altri ordini su target di profitto o stop loss differenti.

    package SQ.Blocks.Order.Open;
    import java.util.ArrayList;
    import com.strategyquant.datalib.TradingException;
    import com.strategyquant.datalib.UpdateEventTypes;
    import com.strategyquant.lib.SQTime;
    import com.strategyquant.lib.SQUtils;
    import com.strategyquant.tradinglib.*;
    // Modified by Emmanuel Evrard for StrategyQuantX Community
    @BuildingBlock(name="(MMKT) Enter Multiple Order at market", display="EnterMultipleOrderAtMarket", returnType=ReturnTypes.Order)
    @Help("Opens Multiple order at current market price")
    public class EnterAtMarketMultiOrder extends ActionBlock 
    {
        @Parameter(defaultValue="Any", category="Basic", showIfDefault=false)
        @Editor(type=Editors.SelectionSymbolsWithAny)
        public String Symbol;
        @Parameter(defaultValue="1", category="Basic")
        @Editor(type=Editors.Selection, values="Long=1,Short=-1")
        public int Direction;
        @Parameter(category="Basic")
        @Editor(type=Editors.Formula, formulaName="Size")
        @Required
        public IFormula Size;
        @Parameter(defaultValue="MagicNumber", category="Order identification", showIfDefault=false)
        @Help("Magic number is used to identify the first trade, it should be unique for every trade you open.")
        public int MagicNumber;
        @Parameter(defaultValue="Number Of Order", category="Order identification", showIfDefault=false)
        @Help("Number Of Order is used to set the quantity of order, Their MagicNumbers are successives to the above MagicNumber")
        public int NbOrder;
        @Parameter(defaultValue="", category="Order identification", showIfDefault=false)
        public String Comment;
        @Parameter(defaultValue="false", category="Order identification", showIfDefault=false)
        @Help("If set to true, it will allow to place multiple trades with the same Magic Number")
        public boolean AllowDuplicateTrades;
        public ExitMethod[] ExitMethods;
        @Override
        public void OnAction() throws TradingException 
        {
            if((!AllowDuplicateTrades || !engineSupportsDuplicateTrades()) && checkLiveOrderExists(0, true) != null) 
                return;
            byte orderType = (Direction > 0 ? OrderTypes.Buy : OrderTypes.Sell);
            double sl = computeSL(orderType, (Direction > 0 ? Strategy.MarketData.Chart(Symbol).Ask() : Strategy.MarketData.Chart(Symbol).Bid()));
            double size = computeSize(orderType, 0, sl);
            ATM atm = Strategy.getATM();
            double pt = computePT(orderType, (Direction > 0 ? Strategy.MarketData.Chart(Symbol).Ask() : Strategy.MarketData.Chart(Symbol).Bid()));
            int MagicNumber1 = MagicNumber;
            for(int i = 0; i < NbOrder; i++) 
            {
                MagicNumber = MagicNumber1 + i;
                if(atm != null && atm.isApplicable(Strategy, size, sl, orderType)) {
                    openATMOrder(atm, -1, size, sl, pt, orderType, 0);
                } else {
                    openNormalOrder(-1, size, sl, orderType, 0);
                }
            }
        }
        protected void openNormalOrder(double openPrice, double size, double sl, byte orderType, int barsValid) throws TradingException {
            ILiveOrder order = Strategy.Trader.Open(orderType, Symbol, openPrice)
                    .setSize(size).setMagicNumber(MagicNumber).setComment(Comment).Send();
            if(order.isSuccessful()) {
                handleBarsValid(order, barsValid);
                for(ExitMethod exitMethod : ExitMethods) {
                    if(!order.isClosedOrder()) exitMethod.setForOrder(order, Strategy);
                }
            }
        }
        protected double computeSL(byte orderType, double orderPrice) throws TradingException {
            ExitMethod slExit = getStopLossExit();
            return slExit == null ? Order.NOT_DEFINED : SQUtils.fixPrice(Strategy.getInstrumentInfo().tickStep, slExit.computeValue(orderType, Strategy, Symbol, orderPrice));
        }
        protected double computePT(byte orderType, double orderPrice) throws TradingException {
            ExitMethod ptExit = getProfitTargetExit();
            return ptExit == null ? Order.NOT_DEFINED : SQUtils.fixPrice(Strategy.getInstrumentInfo().tickStep, ptExit.computeValue(orderType, Strategy, Symbol, orderPrice));
        }
        private ExitMethod getStopLossExit() {
            for(ExitMethod e : ExitMethods) if(e.getExitType() == ExitTypes.StopLoss) return e;
            return null;
        }
        private ExitMethod getProfitTargetExit() {
            for(ExitMethod e : ExitMethods) if(e.getExitType() == ExitTypes.ProfitTarget) return e;
            return null;
        }
        protected double computeSize(byte orderType, double price, double sl) throws TradingException {
            return ((MMFormulaBlock) Size).computeSize(Strategy, Symbol, orderType, price, sl);
        }
        protected ILiveOrder checkLiveOrderExists(int direction, boolean includeClosingOrders) {
            for(int i=Strategy.Trader.getOpenOrdersCount(includeClosingOrders)-1; i>=0; i--) {
                ILiveOrder order = Strategy.Trader.getOpenOrder(i, includeClosingOrders);
                if(order.isMarketOrder() && OrderFunctions.identify(order, Strategy, Symbol, direction, MagicNumber, Comment)) 
                    return order;
            }
            return null;
        }
        protected boolean engineSupportsDuplicateTrades() { return Strategy.Trader.supportsDuplicateTrades(); }
        protected void handleBarsValid(ILiveOrder order, int barsValid) throws TradingException {}
    }
    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-MultipleMarketOrder.sqm12 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 categoryTrading options