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 write R-Breaker strategy

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge of this article "how to write R-Breaker strategy", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to write R-Breaker strategy" article.

1. Summary

The R-Breaker strategy was developed by Richard Saidenberg and made public in 1994. After that, it was selected as one of the top 10 most profitable trading strategies by Futures Truth magazine for 15 years in a row. Compared with other strategies, R-Breaker is a trading strategy that combines trend and reversal. Can not only capture the trend of the market to obtain big profits, but also in the market reversal, timely take the initiative to stop profits and homeopathy backhand.

Resistance level and support level

To put it simply, the R-Breaker strategy is a support and resistance strategy, which calculates seven prices based on yesterday's highest, lowest and closing prices: one central price (pivot), three support levels (S1, S2, S3), and three resistance levels (R1, R2, R3). Then, according to the position relationship between the current price and these support levels and resistance levels, in order to form the trigger conditions of buying and selling, and through certain algorithm adjustment, adjust the distance between the seven prices, and further change the trigger value of the transaction.

Breakthrough buying price (resistance level R3) = yesterday's highest price + 2 * (central price-yesterday's lowest price) 2

Observe selling price (resistance level R2) = central price + (yesterday's highest price-yesterday's lowest price)

Reverse selling price (resistance level R1) = 2 * central price-yesterday's lowest price

Central price (pivot) = (yesterday's highest price + yesterday's closing price + yesterday's lowest price) / 3

Reverse buying price (support level S1) = 2 * central price-yesterday's highest price

Observed buying price (support level S2) = central price-(yesterday's highest price-yesterday's lowest price)

Breakthrough selling price (support level S3) = yesterday's lowest price-2 * (yesterday's highest price-central price)

From this we can see that the R-Breaker strategy is to draw a grid-like price line based on yesterday's prices and update these price lines once a day. In the technical analysis, the support level and the resistance level, and the effects of the two can be converted to each other. When the price successfully breaks through the resistance level upward, the resistance level becomes the support level; when the price successfully breaks down through the support level, the support level becomes the resistance level.

In actual trading, these support and resistance levels point out the trading points such as the direction and precision of opening and closing positions for traders. Specific opening and closing conditions traders can be flexibly customized according to intraday price, central price, resistance level, support level, and can also carry out position management according to these grid price lines.

III. Strategic logic

Next, let's take a look at how the R-Breaker strategy takes advantage of these support and resistance levels. Its logic is not complicated at all. If there is no current position to enter the trend mode, when the price is greater than the breakthrough buying price, open the position and do long; when the price is less than the breakthrough selling price, open the position and short.

Trend pattern

Long opening: if there is no position and the price is higher than the breakthrough purchase price

Short opening: if there is no position and the price is less than the breakthrough selling price

Long closing: if you hold a long order, and the highest price of the day is greater than the observed selling price, and the price is less than the reverse selling price.

Short closing: if you hold a short order and the lowest price of the day is less than the observed buying price, and the price is greater than the reversal buying price.

Reverse mode

Long opening: if you hold a short order and the lowest price of the day is less than the observed buying price, and the price is greater than the reversal buying price.

Short opening: if you hold multiple orders, and the highest price of the day is greater than the observed selling price, and the price is less than the reverse selling price.

Long closing position: if you hold a long order and the price is less than the breakthrough selling price

Short closing: if you hold a short order and the price is greater than the breakthrough purchase price

If you have a position, enter the reversal mode, when you hold a long order, and the highest price of the day is greater than the observed selling price, and the price falls below the reversal selling price, the long position will be closed and the backhand short will be closed. When holding a short order, the lowest price of the day is less than the observed buying price, and if the price breaks through the reversal buying price, the short position will be closed and the backhand will be long.

4. Policy writing''backteststart: 2019-01-01 00:00:00end: 2020-01-01 00:00:00period: 5mexchanges: [{"eid": "Futures_CTP", "currency": "FUTURES"}]''# Policy main function def onTick (): # get data exchange.SetContractType (contract_type) # subscribe futures bars_arr = exchange.GetRecords (PERIOD_D1) # get daily K-line array if len (bars_arr)

< 2: # 如果K线数量小于2根returnyesterday_open = bars_arr[-2]['Open'] # 昨日开盘价yesterday_high = bars_arr[-2]['High'] # 昨日最高价yesterday_low = bars_arr[-2]['Low'] # 昨日最低价yesterday_close = bars_arr[-2]['Close'] # 昨日收盘价# 计算pivot = (yesterday_high + yesterday_close + yesterday_low) / 3 # 枢轴点r1 = 2 * pivot - yesterday_low # 阻力位1r2 = pivot + (yesterday_high - yesterday_low) # 阻力位2r3 = yesterday_high + 2 * (pivot - yesterday_low) # 阻力位3s1 = 2 * pivot - yesterday_high # 支撑位1s2 = pivot - (yesterday_high - yesterday_low) # 支撑位2s3 = yesterday_low - 2 * (yesterday_high - pivot) # 支撑位3today_high = bars_arr[-1]['High'] # 今日最高价today_low = bars_arr[-1]['Low'] # 今日最低价current_price = _C(exchange.GetTicker).Last #当前价格# 获取持仓position_arr = _C(exchange.GetPosition) # 获取持仓数组if len(position_arr) >

0: # if the length of the position array is greater than 0for I in position_arr:if I ['ContractType'] = = contract_type: # if the position variety is equal to the subscription variety if I [' Type']% 2 = 0: # if it is multiple single position = I ['Amount'] # the number of positions is positive else:position =-I [' Amount'] # the number of positions is negative profit = I ['Profit' ] # get position profit and loss else:position = 0 # assign position number to 0profit = 0 # position profit and loss to 0if position = = 0: # if there is no position if current_price > R3: # if the current price is greater than the resistance level 3exchange.SetDirection ("buy") # set the trading direction and type exchange.Buy (current_price + 1) 1) # multiple single if current_price

< s3: # 如果当前价格小于支撑位3exchange.SetDirection("sell") # 设置交易方向和类型exchange.Sell(current_price - 1, 1) # 开空单if position >

0: # if you hold multiple if today_high > R2 and current_price

< r1 or current_price < s3: # 如果今日最高价大于阻力位2,并且当前价格小于阻力位1exchange.SetDirection("closebuy") # 设置交易方向和类型exchange.Sell(current_price - 1, 1) # 平多单exchange.SetDirection("sell") # 设置交易方向和类型exchange.Sell(current_price - 1, 1) # 反手开空单if position < 0: # 如果持有空单if today_low < s2 and current_price >

S1 or current_price > R3: # if today's lowest price is less than support level 2 And the current price is greater than the support level 1exchange.SetDirection ("closesell") # set transaction direction and type exchange.Buy (current_price + 1,1) # flat single exchange.SetDirection ("buy") # set transaction direction and type exchange.Buy (current_price + 1) 1) # backhand multiple orders # Program main function def main (): while True: # Loop onTick () # execution Policy main function Sleep (1000) # dormant for more than 1 second is the content of the article "how to write R-Breaker policies" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to 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