English
Back
No matches yet
Operations too frequent. Please try again later.
Please check network settings and try again Refresh Refresh
Loading
History record delete
    Quotes All >
      News All >
        Log in to access Online Inquiry
        Back to the Top

        What is a global variable

        1. What is a global variable

        A global variable is a custom variable. You can create multiple global variables in a single strategy. There are two types of global variables: 
        1. Numeric global variables: This kind of global variable can be used to record integers or decimals. When setting parameters in conditions/operations, numeric global variables can be used to assign values. For example, create a numeric global variable "a" and set it to "Buy 'a' shares of Apple (AAPL.US)" in the Order Conditions.
        2. Symbol global variables: You can directly select the symbol in other conditions/operations without repeatedly searching symbols. For example, if you create a symbol global variable "a" and designate it as Tesla (TSLA.US), it will be set directly to "Buy one share of 'a'" in the Order Conditions.

         

        2. How to create a global variable in a strategy

        Create a variable A in the "Start" properties, with an initial value of the stock's latest price. Please note that global variables are only assigned an initial value when the strategy starts, which is the current stock price.

        (Please note that the application interface and its content shown above may differ from the actual application interface and content. To avoid any discrepancies, please update the application to the latest version available. The securities mentioned in the screenshot are for illustrative purposes only and should not be construed as investment advice.)

        You can assign the value A to the global variable A with the "Value Assignment" card and then print the value of the global variable in the Running Log on the Backtest page. 

        (Please note that the application interface and its content shown above may differ from the actual application interface and content. To avoid any discrepancies, please update the application to the latest version available. The securities mentioned in the screenshot are for illustrative purposes only and should not be construed as investment advice.)

         

        The value of the global variable A is displayed in the running log, and it will always be a constant value (see below).

        (Please note that the application interface and its content shown above may differ from the actual application interface and content. To avoid any discrepancies, please update the application to the latest version available. The securities mentioned in the screenshot are for illustrative purposes only and should not be construed as investment advice.)

         

        3. How to keep a global variable always at the latest stock price when a strategy is running

        Suppose you want to keep the value of the global variable A to be the latest stock price when the strategy is running. In that case, you can assign the latest stock price to variable A with the "Value Assignment" card.

        (Please note that the application interface and its content shown above may differ from the actual application interface and content. To avoid any discrepancies, please update the application to the latest version available. The securities mentioned in the screenshot are for illustrative purposes only and should not be construed as investment advice.)

        This way, the global variable A will hold the updated latest price value.

        (Please note that the application interface and its content shown above may differ from the actual application interface and content. To avoid any discrepancies, please update the application to the latest version available. The securities mentioned in the screenshot are for illustrative purposes only and should not be construed as investment advice.)

         

        This presentation is for informational and educational use only and is not a recommendation or endorsement of any particular investment or investment strategy. Investment information provided in this content is general in nature, strictly for illustrative purposes, and may not be appropriate for all investors.  It is provided without respect to individual investors’ financial sophistication, financial situation, investment objectives, investing time horizon, or risk tolerance. You should consider the appropriateness of this information having regard to your relevant personal circumstances before making any investment decisions. Past investment performance does not indicate or guarantee future success. Returns will vary, and all investments carry risks, including loss of principal. Moomoo makes no representation or warranty as to its adequacy, completeness, accuracy or timeliness for any particular purpose of the above content.