Introduction
Common Scenarios
How to build a strategy as a newbie
How to use the trigger symbol
How to Use Global Variables
How to Determine Buying Power
How to recover the original strategies
How to handle exceptions in strategy running
Learn more from our instructional videos
How to identify problems in a strategy
How to Open and Close Positions
How to avoid repeated opening of positions
How to Set Trigger Conditions to Run a Strategy
How to trade options with the Algo function
Catch exceptions to improve your strategies
Card Description
Backtest
If a signal continuously meets the condition, the strategy may repeatedly execute the ”Place Order Card” .
Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations.
How to ensure the strategy buys or sells only once when the signal meets the condition? Here are the two simplest methods.
If the strategy places a type of order that can be filled quickly (e.g., a market order), then you can indirectly determine whether a position has been opened or closed successfully through the underlying stocks you are holding.
● If the number of underlying stocks you are holding is > 0, then the position has been opened successfully, and the path to close positions will run;
● If the number of underlying stocks you are holding is 0, then the position has been closed successfully or has not been opened, and the path to open positions will run;
Note: This method requires that the order must be filled quickly; otherwise repeated orders may still be placed.
Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations.
If the strategy places a type of order that may not be filled quickly (e.g., a limit order), you can create a value global variable as a counter to indicate whether an order has been placed.
Step 1: Go to “Start Card" > Properties > Global Variables, and create a counter named "a" to indicate whether a buy/sell order has been placed.
● If a buy order has been placed and has held position , it will be represented by 1;
● If no order has been placed and no position is held, it will be represented by 0;
According to the above rules, the value of the global variable "a" is 0 by default (indicating that no order has been placed and no position is held).
Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations.
Step 2: Determine the global variable "a" and the number of holdings first when the strategy starts to run:
● If "a" = 0, and the number of holdings = 0, it means that no order has been placed and no position is held, and the path to open positions will run;
● If "a" = 1, and the number of holdings > 0, it means that a buy order has been placed and there are positions held (the buy order has been filled), and the path to close positions will run;
Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations.
Step 3: Add a "Value Assignment Card" after the "Place Order Card", and re-assign value to the global variable "a":
● Path to close positions: re-assign 0 to the global variable "a" to indicate a sell order has been placed.
● Path to open positions: re-assign 1 to the global variable "a" to indicate a buy order has been placed.
Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations.
Risk Disclosure 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.