A, in this paper,
For trading beginners, building strategies through technical indicators is the simplest way to start quantitative trading. In this paper, we develop a Chandler momentum swing (CMO) strategy to achieve quantitative trading of commodity futures.
CMO principle
What do you think caused the price to go up or down? Macro policies, news events, supply and demand relations, market sentiment and so on, all of these may affect traders’ psychological expectations, and finally implement the behavior: buy, sell, wait and see. For a stock, if there are more people buying than selling, the price will rise, if there are more people selling than buying, the price will fall, and the final price rise or fall is the result of the competition between the forces of the many sides and the forces of the short side, if the many sides are stronger than the forces of the short side, the price will rise, and vice versa. The Chandler momentum swing (CMO) measures the kinetic energy behind the price.
CMO introduction
The Chandler momentum swing (CMO) is the product of Tushar Chande, who is himself a scientist and a brilliant systematic trader. There are many momentum swing indicators on the market, such as relative strength index (RSI) and stochastic index (KDJ), but the Chandler momentum swing (CMO) is unique in its calculation formula using the data of rising and falling days in the numerator.
4. CMO calculation formula
In the CMO calculation formula below, the numerator uses the data of rising and falling days.
CMO=((Su-Sd)*100)/(Su+Sd)
Su is the sum of the difference between today’s closing price and yesterday’s closing price (rising day). If the day falls, then the added value is 0; Sd is the absolute sum of the difference between today’s close and the day’s close (the day of decline). If it goes up that day, the added value is 0.
CMO usage
1, zero axis cross CMO can be regarded as a long signal through the zero axis, can be regarded as a short signal through the zero axis. 2. The overbought/oversold CMO moves between -100 and 100. As a general rule, the CMO quantifies extremely overbought levels above +50 and extremely oversold levels below -50. In theory, CMO should lead to price. If the price hits a new high, but CMO does not hit a new high, or even goes down, then the rising trend of price may be about to reverse; If prices hit a new low, but the CMO does not, or even moves higher, the downward trend may be about to reverse. 4. The absolute value of the absolute value of CMO can also measure the trend strength of the price. The higher the absolute value of CMO is, the stronger the trend strength is; the lower the absolute value is, the weaker the trend strength is. In this way, the absolute value switching strategy of CMO can be used. When the absolute value of CMO is high, it is switched to trend tracking strategy; when the absolute value of CMO is low, it is switched to mean regression strategy.
Strategic logic
According to the CMO usage above, create a simple Chandler momentum swing (CMO) strategy. The strategy logic is as follows:
- Long open: If there is no open position, the price is above the long term average, and the absolute value of the CMO is greater than 50
- Short open: If there are no open positions, the price is below the long term average, and the absolute value of the CMO is greater than 50
- Long liquidation: If you are currently long and the price is below the short term average
- Short closing: If you are currently holding a short order and the price is above the short-term average
7. Strategy implementation
'''backtest start: 2017-01-01 00:00:00 end: 2020-12-01 00:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] ma_length = 150 cmo_length = 10 cmo_value = 10 Import talib import numpy as NP # define the global variable, record the open position mp = 0 # get the closing data in the list of K lines def get_data(bar): arr = [] for i in bar: arr.append(i['Close']) return arr def bar(): If len(bar) < ma_length: Price = bar[-1]['Close'] # np_arr = np.array(get_data(bar)) # Cmo = abs(np_arr, cMO_length)[-1]) Ma2 = talib.ma (np_arr, Ma_length / 2)[-1] ma_length / 2 # If you are currently holding multiple orders, Exchange.SetDirection("closebuy") # set the type of exchange. If mp < 0 and price > ma2: # If you are holding a short order, Exchange.SetDirection("closesell") # set the type of exchange.Buy(price, Cmo = 0 and abs(cmo) > cmo_value: If price > ma1 and CMO value > ma2 and CMO value > ma2 Exchange.SetDirection("buy") # Set the type of exchange. If price < ma1 and price < ma2: Exchange.SetDirection("sell") exchange. 1) # open empty single mp = 1 # reset virtual holdings def main () : _C (exchange. SetContractType, 'c000') # subscription prices while True: # Enter wireless loop mode bar() # repeat bar function Sleep(1000) # put the program to Sleep for 1 secondCopy the code
Full policy address: www.fmz.com/strategy/23… Open this link to copy the full policy and back test it online.
Eight, strategy back test
- Start date: 2017-01-01
- Test end date: 2020-12-01
- Data species: maize index
- Data cycle: daily line
- Slip point: 2 jumps for each open position
Back to the test configuration To measure performance Returns an overview
Nine,
Simple chandler wobble (CMO) momentum strategy in corn index test is good, the last time especially when the market price movements is smooth, the policy proceeds will be better, but if the market price at shock stage, the strategy can appear even losses in a row, so choose larger cycle is a relatively wise choice, it’s important to note that this policy is not set full stop, The results of the back test may contain potential risks and benefits.