Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use regression amplitude to construct Multi-variety reversal Strategy in Internet

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

I would like to share with you how to use the range of regression to build a multi-variety reversal strategy on the Internet. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. let's learn about it!

Principle of strategy

Price reversal is the result of energy conversion, and it is a difficult process, which requires sufficient time and space for energy exchange. But like the law of conservation of energy, time can be exchanged for space, on the contrary, space can counteract time. In the reversal, there is not only a fierce single-day V-shaped reversal, but also a time-consuming dome and dome, V-shaped reversal, straight, clean and clean, without any breathing time.

Relatively speaking, reversals based on fixed points may be subject to changes in variety price volatility, but reversals based on fixed percentage ranges are less likely to suffer similar troubles, unless the volatility level of the variety has changed. This strategy is based on this point.

Similarly, in this strategy, it does not define how to distinguish between trends and shocks, but goes straight to the point and opens positions based on the relationship between current prices and previous highs and lows. Because whether it is a trend or shock, these are only a concept of artificial subjective definition, before the market comes out, no one knows whether it is a trend or shock, so these subjective definitions are typical concepts used in post-analysis.

Moreover, under the framework of different time and trend structure, shock and trend are basically difficult to define accurately, and the concussion of large cycle is the trend of small cycle. That is to say, before the market comes out, it is meaningless to analyze and define the volatility and trend of the market.

Strategy construction

In the first step, let's take a look at the strategy framework. In the Strategy Square of the fmz website, there are many different kinds of strategy frameworks. These frameworks can be used for different types of strategies, simple and convenient, and save a lot of time. For example, the use of regression amplitude to build a multi-variety reversal strategy in this article is more suitable to use the CTA strategy framework. For specific usage, you can refer to this link

The policy framework automatically provides data and basic services in the background, with the help of the policy framework can greatly improve the efficiency of policy writing, normal hundreds of lines of policy, using dozens of lines of CTA policy framework can achieve a concurrent, stable and real multi-variety strategy. In addition, with special programmed transaction data structure and rich financial statistics function library, it also supports complex logical applications, simple and flexible. As follows:

Function main () {$.CTA ("RB000,RU000,CF000,TA000,I000,PP000,P000,L000,J000,JM000", function (st) {var bars = st.records; / / get K-line array / / K-line length filter if (bars.length)

< 20) { return } var unit = 1; // 下单数量 var buyToOpen = '多头开仓条件'; var buyToClose = '多头平仓条件'; var sellToOpen = '空头开仓条件'; var sellToClose = '空头平仓条件'; // 多头平仓 if (buyToClose) { return -unit; } // 空头平仓 if (sellToClose) { return unit; } // 多头开仓 if (buyToOpen) { return unit; } // 空头开仓 if (sellToOpen) { return -unit; } });} 第二步,开始在CTA框架中填充策略逻辑,首先给每个合约创建一个仓位表。大家知道,不同品种在不同行情中,开平仓的时机是不一样的,比如:螺纹钢开了多单,橡胶开了空单;或者螺纹钢平仓了,橡胶还持有空单。所以仓位表可以针对具体合约分别记录和管理持仓,如下: contractType = 'rb000/rb888,ru000/ru888'; // 合约类型var contractType_Dic = {}; // 创建一个空对象,用于接收不同的合约类型var contractType_Array1 = contractType.split(","); // 分割合约类型参数var contractType_Array2 = []; // 创建一个空数组,用于接收不同的交易合约for (var i = 0; i < contractType_Array1.length; i++) { // 遍历每个设置的合约 contractType_Array2.push(contractType_Array1[i].split('/')[1]); // 分别存储交易合约}contractType_Array2.toString(); // 把数组转变为字符串for (var key in contractType_Array2) { // 遍历字符串 contractType_Dic[contractType_Array2[key]] = { falsePosition: 0 // 把每个交易合约的初始仓位赋值为0 }}Log(contractType_Dic) // 查看处理好的仓位表,打印:{ rb888: { falsePosition: 0 }, ru888: { falsePosition: 0 } } 第三步,把策略开平仓逻辑写到里面就可以了。其中用到了K线周期内最高价和最低价与当前价格的相互位置关系。策略没有附带止盈止损,只有开仓和平仓,核心思想就是:截断亏损,让利润奔跑!大家注意看下面策略代码中的注释。 多头开仓:如果当前没有持仓,并且价格大于前 N 根 K 线内的最低价 + 百分比幅度。 空头开仓:如果当前没有持仓,并且价格小于前 N 根 K 线内的最高价 - 百分比幅度。 多头平仓:如果当前持有多单,并且价格小于前 N 根 K 线内的最低价与前 N 根 K 线内的最高价的和的一半。 空头平仓:如果当前持有空单,并且价格大于前 N 根 K 线内的最低价与前 N 根 K 线内的最高价的和的一半。 function main() { // 参数 cycleLength = 50; // 周期长度 backRatio = 1; // 回撤比率 contractType = 'rb000/rb888,ru000/ru888'; // 合约类型 unit = 1; // 下单数量 // 仓位表 var contractType_Dic = {}; // 创建一个空对象,用于接收不同的合约类型 var contractType_Array1 = contractType.split(","); // 分割合约类型参数 var contractType_Array2 = []; // 创建一个空数组,用于接收不同的交易合约 for (var i = 0; i < contractType_Array1.length; i++) { // 遍历每个设置的合约 contractType_Array2.push(contractType_Array1[i].split('/')[1]); // 分别存储交易合约 } contractType_Array2.toString(); // 把数组转变为字符串 for (var key in contractType_Array2) { // 遍历字符串 contractType_Dic[contractType_Array2[key]] = { falsePosition: 0 // 把每个交易合约的初始仓位赋值为0 } } // CTA框架 $.CTA(contractType, function(st) { var bars = st.records; // 获取K线数组 var j = bars[bars.length - 2].Close; // 获取上根K线收盘价 var high = TA.Highest(bars, cycleLength, 'High'); // 计算N日内的最高价 var low = TA.Lowest(bars, cycleLength, 'Low'); // 计算N日内的最低价 var highBack = high * (1 - backRatio / 100); // 计算N日内的最高价的回撤1%的值 var lowBack = low * (1 + backRatio / 100); // 计算N日内的最低价的回撤1%的值 // 过滤K线数量 if (!bars || bars.length < cycleLength + 1) { return; } //多头平仓 if (contractType_Dic[st.symbol].falsePosition >

0 & & j

< (lowBack + highBack) / 2) { contractType_Dic[st.symbol].falsePosition = 0; return -unit; } //空头平仓 if (contractType_Dic[st.symbol].falsePosition < 0 && j >

(lowBack + highBack) / 2) {contractType_ Dic [ST.symbol] .falsePosition = 0; return unit;} / / long opening if (contractType_ DIC [ST.symbol] .falsePosition = = 0 & & j > lowBack & & j > highBack) {contractType_ Dic [ST.symbol] .falsePosition = 1; return unit } / / short opening if (contractType_ Dic [ST.symbol] .falsePosition = = 0 & & j < lowBack & & j < highBack) {contractType_ DIC [ST.symbol] .falsePosition =-1; return-unit;}});}

The source code of the complete policy has been disclosed to the inventor to quantify the https://www.fmz.com/strategy/69937, and there is no need to configure the direct backtest.

Strategy improvement

Overall, this is a highly versatile strategy. Of course, this is just a simple strategic idea, which may be improved elsewhere:

1. Increase the volatility factor. We all know that each breed has its own character, and the fundamentals and technical aspects influence each other. Increasing the volatility factor can more objectively reflect the price trend of the current variety.

2. Change the fixed period to the adaptive period. In fact, there is only one core parameter for this strategy, and the parameter is fixed. If we add or subtract the fixed parameters dynamically through the relationship between the speed of price change and acceleration, we can more immediately reflect the market at that time.

3. Change the percentage back to a fixed value. For example, if the current price is 1000, 1% is 10; if the current price is 5000, 1% is 50. There is a difference of several orders of magnitude between 10 and 50. For the same type of contract, the opening and closing conditions vary greatly because of the current price in different periods.

The above is all the contents of the article "how to use regression amplitude to construct multi-variety reversal strategy in the Internet". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report