StrategyQuant
Q AI AssistantAlgoCloudQuantAnalyzerQuantDataManager
Free CourseCompany
BlogDocumentationForumContact us
BlogMarketplace
Log in
Create free account

Product

  • Pricing & licenses
  • Learn
  • Marketplace
  • Start free trial

Legal

  • Terms of Service
  • Privacy Policy
  • Cookies

Contact

[email protected]

Company

StrategyQuant s.r.o.

Korunní 2569/108, Vinohrady, 101 00 Praha 10, Czech Republic, EU

IČ: 04000498

DIČ: CZ04000498

Social

  • Legal Notice | PROCESSING AND PROTECTION OF PERSONAL DATA

    Past performance is no guarantee of future success. All information should be viewed as educational only

    UNITED STATES Disclaimer required by Government - Commodity Futures Trading Commission informs: Futures and options trading have great potential rewards, but also great potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to buy/sell futures, shares or options on the same. No representation is being made that any account will or is likely to realise profits or losses similar to those discussed in this document. The past performance of any trading system or methodology is not necessarily indicative of future results.

    CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE A RECORD OF ACTUAL PERFORMANCE, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES WERE NOT EXECUTED, THE RESULTS MAY HAVE OFFSET THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMMES IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO REALISE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN.

    NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL, OR IS LIKELY TO, REALISE PROFITS OR LOSSES SIMILAR TO THOSE DISCUSSED WITHIN THIS SITE. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS IN THE FINANCIAL MARKETS SHOULD BE YOUR OWN.

    © StrategyQuant 2026

    Powered by Klaudie.ai

    Back to marketplaceDIGITAL

    Batch Rename Strategies

    StrategyQuantPlugins
    Batch Rename Strategies

    Batch rename all strategies in a databank using find & replace patterns. Ideal for cleaning naming conventions, removing prefixes/suffixes, and standardizing strategy names across your library.

    Ideal if you want to quickly create clean, informative names across a whole databank – this Custom Analysis snippet lets you batch rename strategies in StrategyQuant X using simple find → replace (or just find → remove).

    — What it does

    • Runs as a Custom Analysis (Full databank analysis).
    • Input args accepts find=>replace or just find to remove.
    • Renames in place in the selected Source databank.
    • Literal, case-sensitive match. Supports \n, \t, \r.
    • Great for mass cleaning: trim prefixes/suffixes, remove words, standardize symbols/timeframes/directions.

    — How to install

    1. Code Editor → New → Custom Analysis, name the file CARenameFindReplace
    2. Paste the code (below) and Compile.
    3. If needed, restart SQX.

    — How to use

    1. Custom Project → Task → Custom Analysis. (Can also be run inside a databank from Databank > Tools > Run CA).
    2. In Full databank analysis, select CARenameFindReplace and choose your Source databank.
    3. In Input args enter one of:
    -
    Replace: old=>new
    Remove: old
    -
    4. Enable 'Filter by results of custom analysis' to rename the original strategies. (If you disable this, the strategies will be duplicated and only the duplicates renamed, leaving the originals untouched.)
    5. Run. All strategy names in the Source databank are updated.

    — Examples

    • Remove the word “Strategy ” (with trailing space):
    Strategy =>
    • Convert SQX auto-name to a formatted label:
    Strategy =>XAUUSD_H1_L_
    • Strip dots after a prefix pass:
    .=>

    Tip: Run multiple passes for multi-step formatting (e.g., add a prefix, then strip characters, then add a suffix). Consider duplicating the databank first if you want an easy rollback.

    Code:

    package SQ.CustomAnalysis;
    import com.strategyquant.tradinglib.*;
    import com.strategyquant.tradinglib.project.ProjectEngine;
    import com.strategyquant.tradinglib.project.SQProject;
    import java.util.ArrayList;
    import java.util.HashSet;
    public class CARenameFindReplace extends CustomAnalysisMethod {
        public CARenameFindReplace() {
            super("CARenameFindReplace", TYPE_PROCESS_DATABANK);
        }
        @Override
        public boolean filterStrategy(String project, String task, String databankName, ResultsGroup rg) throws Exception {
            return true;
        }
        @Override
        public ArrayList processDatabank(
                String project,
                String task,
                String databankName,
                ArrayList databankRG) throws Exception {
            // Read single Input args string
            String raw = getInputArgs();
            if (raw == null) raw = "";
            raw = raw.trim();
            // No args -> do nothing
            if (raw.isEmpty()) {
                return databankRG;
            }
            // Parse: "find=>replace" OR just "find" (remove)
            String find, repl;
            int arrow = raw.indexOf("=>");
            if (arrow >= 0) {
                find = raw.substring(0, arrow);
                repl = raw.substring(arrow + 2);
            } else {
                find = raw;
                repl = "";
            }
            find = unescape(find);
            repl = unescape(repl);
            // If find is empty, do nothing (prevents accidental rename-all)
            if (find.isEmpty()) {
                return databankRG;
            }
            SQProject prj = ProjectEngine.get(project);
            Databank db = prj.getDatabanks().get(databankName);
            // Snapshot of originals to avoid ConcurrentModificationException
            ArrayList snapshot = new ArrayList<>(databankRG);
            // Track existing names so we can avoid collisions if needed
            HashSet usedNames = new HashSet<>();
            for (ResultsGroup rg : snapshot) {
                if (rg.getName() != null) usedNames.add(rg.getName());
            }
            // 1) Create renamed clones (no db.add inside the iteration)
            ArrayList clonesToAdd = new ArrayList<>();
            for (ResultsGroup rg : snapshot) {
                String oldName = rg.getName();
                if (oldName == null) continue;
                String newName = oldName.replace(find, repl);
                // Only duplicate if name changes
                if (!newName.equals(oldName)) {
                    // Avoid exact-name collisions (optional safety)
                    String finalName = makeUniqueName(newName, usedNames);
                    ResultsGroup newRg = rg.clone();
                    newRg.setName(finalName);
                    clonesToAdd.add(newRg);
                    usedNames.add(finalName);
                }
            }
            // 2) Add clones after iteration (safe)
            for (ResultsGroup newRg : clonesToAdd) {
                db.add(newRg, true);
            }
            // Return the newly created strategies (mirrors SQX RenameStrategies behaviour)
            return clonesToAdd;
        }
        private static String makeUniqueName(String baseName, HashSet used) {
            if (!used.contains(baseName)) return baseName;
            int i = 2;
            while (true) {
                String candidate = baseName + "_" + i;
                if (!used.contains(candidate)) return candidate;
                i++;
            }
        }
        private static String unescape(String s) {
            if (s == null) return "";
            return s.replace("\\n", "\n")
                    .replace("\\t", "\t")
                    .replace("\\r", "\r");
        }
    }
    
    Past performance is no guarantee of future success. All information should be viewed as educational only UNITED STATES Disclaimer required by Government - Commodity Futures Trading Commission informs: Futures and options trading have great potential rewards, but also great potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to buy/sell futures, shares or options on the same. No representation is being made that any account will or is likely to realise profits or losses similar to those discussed in this document. The past performance of any trading system or methodology is not necessarily indicative of future results. CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE A RECORD OF ACTUAL PERFORMANCE, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES WERE NOT EXECUTED, THE RESULTS MAY HAVE OFFSET THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMMES IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO REALISE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL, OR IS LIKELY TO, REALISE PROFITS OR LOSSES SIMILAR TO THOSE DISCUSSED WITHIN THIS SITE. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS IN THE FINANCIAL MARKETS SHOULD BE YOUR OWN.
    Free

    Files

    • Snippet-BatchRenameStrategies.sqm5 KBLocked

    Download unlocks after purchase or with an active tier.

    Details
    Version1.0.0
    PublishedOctober 19, 2026
    Last updatedNovember 2, 2026
    AppSQ
    TypeSnippet
    AuthorZach
    App version145.3058
    Codebase categoryCustom Analysis