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

    Read Strategy Init Variables

    StrategyQuantPlugins
    Read Strategy Init Variables

    Custom Analysis example showing how to read variable values from Strategy Init rules. Demonstrates toInitValue usage to access initialization parameters and create custom databank columns.

    In a rule triggered on Strategy Init, for each Assign function, StrategyQuant assign a “AssignVrbVleEntMlt” variable to your variable instead of a value.

    Then, during initialization, it will give back the AssignVrbVleEntMlt value to your variable

    From a strategy produced by the “H1388 Test Variable Template“, we can read in the code :

    AssignVrbVleEntMlt = 210

    AssignVrbVleEntMlt is receiving the value at the place MALength

    Then AssignVrbVleEntMlt give back the value to MALength at Inialization.


    1/ This Custom Analysis Code example show you how to get a value of your variable in a rule triggered on strategy Init

    We get the value from a function “toInitValue“, from a ResultsGroup, and Rule name “Init“, and a variable name : MALength (In this example)

    Then we are using rg.specialValues() function to set the value in “CA_MALength”

    package SQ.CustomAnalysis;
    import com.strategyquant.lib.*;
    import java.util.ArrayList;
    import com.strategyquant.datalib.*;
    import com.strategyquant.tradinglib.*;
    import SQ.Utils.Bouillant;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import java.util.*; 
    // Created in France by Emmanuel Bouillant-Evrard
    public class CA_InitStratsSettings extends CustomAnalysisMethod 
    {
        public static final Logger Log = LoggerFactory.getLogger(CA_InitStratsSettings.class);
        public CA_InitStratsSettings() 
        {
            super("CA MALength Settings", TYPE_FILTER_STRATEGY);
        }
        //------------------------------------------------------------------------
        @Override
        public boolean filterStrategy(String project, String task, String databankName, ResultsGroup rg) throws Exception 
        {
            try 
            {
                Bouillant BouilltParaObj1 = new Bouillant();
                String IntTemp = BouilltParaObj1.toInitValue(rg, false,"Init", "MALength", 100); 
                rg.specialValues().set("CA_MALength", Double.parseDouble(IntTemp));
                return true;
          	} catch(Exception e)
            {
                Log.error("Error CA_InitStratsSettings", e);
                return false;																																							       // "Error: " + e.getMessage();
            }
        }
        //------------------------------------------------------------------------
        @Override
        public ArrayList<ResultsGroup> processDatabank(String project, String task, String databankName, ArrayList<ResultsGroup> databankRG) throws Exception {
            return databankRG;
        }
    }


    2 / Then the DatabankColumn code retrieve the value of the Custom Analysis

    We are using rg.specialValues to retrive the value from CA_MALength
    package SQ.Columns.Databanks;
    import com.strategyquant.lib.*;
    import com.strategyquant.datalib.*;
    import com.strategyquant.tradinglib.*;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    // Created in France by Emmanuel Bouillant-Evrard 
    public class StratSettingsMALength extends DatabankColumn 
    {
      public static final Logger Log = LoggerFactory.getLogger(StratSettingsMALength.class);
      public StratSettingsMALength()
      {
        super("MALength Settings", DatabankColumn.Decimal2, ValueTypes.Maximize, 0, 0, 100); 
      }
      //------------------------------------------------------------------------
      /**
       * This method should return computed value of this new column. You should typically compute it from the list of orders 
       * or from some already computed statistical values (other databank columns). 
       */
      @Override
      public String getValue(ResultsGroup rg, String resultKey, byte direction, byte plType, byte sampleType) throws Exception 
      {   
        try 
        {
          double value = rg.specialValues().getDouble("CA_MALength", -1);
          if(value == -1) 
          {
            // this means value was not set
            return NOT_AVAILABLE;
          } else 
          {
            // return value converted to String
            return java.lang.Double.toString(value);
          }
        } catch(Exception e)
        {
          Log.error("Error StratSettingsMALength", e);
          return "";																																							       // "Error: " + e.getMessage();
        }
      }
    }


    3/ How to install it

    • Import the snippets in the Code Editor
    • Compile All
    • Restart StrategyQuant
    • then select the Custom Analysis in the Builder:

    Then we add this new column to a Databank and read the value of our Init rules

    If the Custom Analysis is not used anymore, the Column Databank must be removed to avoid any error in the log


    My name is Emmanuel Bouillant-Evrard, Engineer specialized in Finance. I worked in Research and Development in Finance in USA, Canada and France for 24 years.

    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-ReadStrategyInitVariables.sqm20 KBLocked

    Download unlocks after purchase or with an active tier.

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