English
Back
• Investment Choices
• Features
• Pricing
• Insights
• Quotes
• News
• Moo Community
• Learn
• Support
• Promotions
• English
• 中文繁體
• 中文简体
• Dark
• Light
No matches yet
Operations too frequent. Please try again later.
Please check network settings and try again Refresh Refresh
History record
Quotes All >
News All >
Back to the Top

# How to build a strategy as a newbie

If you have a good idea, you may wonder how to realize it and quickly build a strategy on the canvas.

## 1. How to build a simple strategy to open and close positions only

First of all, we must identify the conditions under which we want the strategy to open and close positions.

Let's take the Double Moving Average (Double MA) strategy as an example. The Double MA strategy is to buy when the shorter-term moving average (MA) is above the longer-term MA, and sell when the shorter-term MA crosses below the longer-term MA.

With this idea in mind, let's quickly figure out the paths to open and close positions. The upper path is to determine when to open positions, while the lower path, to close positions.

When MA(5) is above MA(10), open a position; when MA(5) is below MA(10), close positions.

But this strategy is not yet perfect. There is a serious problem:

MA(5) may be continuously above MA(10) (golden cross) when the stock price is rising. If a position is opened every time it is determined that this condition is met, it won’t be long before your cash is used up(and margin may even be used), which is not what we expected.

If MA(5) is above MA(10) all the time, we would like to buy once only. Similarly, if MA(5) is always below MA(10) (dead cross), we also wish to close positions only once.

How can we achieve this?

All we need is to add a condition to determine whether there is any position: The strategy determines whether to open a position only when there is no position, and whether to close a position only when there is a position.

In this way, when the condition to open a position is met and the position is opened, we will hold the underlying stock in our position, and then the orange path will run and there will be no repeated opening of positions.

In order to make the whole strategy more robust, we add a condition on buying power before opening a position to ensure that the order will not fail due to insufficient buying power.

With this idea in mind, you may find our Double MA strategy not so hard to understand.

Any images provided are not current and any securities shown are for illustrative purposes only and are not recommendations.

By summarizing the above idea into a methodology, we get a general template for simple strategies to open and close positions.

To create similar strategies later, you only need to apply the template and fill in the corresponding conditions to open and close positions.

## 2. How to set an adding-to-positions condition

It is very simple to build a strategy to add to positions. Just add the green part to the original strategy. When the condition to close positions is not met, the strategy will determine whether the condition to add to positions is met. If this condition is met, an order can be placed to add to positions.

Of course, don’t forget to make this condition to iterateat the end in case it is continuously met and the strategy will soon use up our cash.

At the end of your strategy, consider updating the add-positions condition with a Value Assignment card. Otherwise, if the condition is consistently met, the strategy could add positions continuously, potentially leading to a quickly filled position.

## 3. How to set take-profit and stop-loss conditions

It is also very simple to build a strategy to take profit and stop loss. Just replace the condition to close positions with the condition to take profit and close position as shown in the orange part, and then add a similar path as shown in the purple part.

When the condition to take profit and close position is not met, the strategy will determine whether the condition to stop loss is met. If this condition is met, close position.

## 4. How to set an adding-to-positions condition and take-profit and stop-loss conditions

By integrating the purple part (stop-loss condition) and the green part (adding-to-positions condition) above, we get a template for a strategy that can not only add to positions, but also take profit and stop loss.

When there is a position, the strategy first determines whether the condition to take profit and close positions is met; if so, it will take profit (close all positions). If that condition is not met, the strategy determines whether the condition to stop loss and close positions is met; if so, it will stop loss (close all positions). If that condition is not met, the strategy determines whether the condition to add to positions is met; if so, it will place an order to add to the positions and make theadding-to-positions condition to iterate.

Losses can happen more quickly with quant and algorithmic trading compared to other forms of trading. Trading in financial markets carries inherent risks, making effective risk management a crucial aspect of quantitative trading systems. These risks encompass various factors that can disrupt the performance of such systems, including market volatility leading to losses.
Moreover, quants face additional risks such as capital allocation, technology, and broker-related uncertainties. It's important to note that automated investment strategies do not guarantee profits or protect against losses.
The responsiveness of the trading system or app may vary due to market conditions, system performance, and other factors. Account access, real-time data, and trade execution may be affected by factors such as market volatility.

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.