Camarilla Pivot Points Strategy dựa trên Bollinger Bands

Tác giả:ChaoZhang, Ngày: 2024-02-05 14:23:59
Tags:

img

Tổng quan

Chiến lược này đầu tiên tính toán các điểm pivot Camarilla dựa trên giá cao nhất, giá thấp nhất và giá đóng cửa của ngày giao dịch trước. Sau đó nó lọc giá bằng chỉ số Bollinger Bands để tạo ra tín hiệu giao dịch khi giá vượt qua các điểm pivot.

Chiến lược logic

  1. Tính toán giá cao nhất, giá thấp nhất và giá đóng cửa của ngày giao dịch trước
  2. Tính toán các đường pivot Camarilla bao gồm đường ray trên H4, H3, H2, H1 và đường ray dưới L1, L2, L3, L4 theo công thức
  3. Tính toán đường băng Bollinger 20 ngày đường băng trên và đường băng dưới
  4. Đi dài khi giá phá vỡ trên dải dưới, đi ngắn khi giá phá vỡ dưới dải trên
  5. Đặt lệnh dừng lỗ gần dải Bollinger Bands trên hoặc dưới

Phân tích lợi thế

  1. Các đường pivot Camarilla chứa nhiều mức hỗ trợ và kháng cự chính để tăng độ tin cậy của tín hiệu giao dịch
  2. Kết hợp với Bollinger Bands có hiệu quả lọc breakout giả
  3. Sự kết hợp nhiều tham số làm cho giao dịch linh hoạt

Phân tích rủi ro

  1. Cài đặt tham số Bollinger Bands không chính xác có thể gây ra tín hiệu giao dịch sai
  2. Các điểm pivot Camarilla phụ thuộc vào giá ngày giao dịch trước, có thể bị ảnh hưởng bởi các lỗ hổng qua đêm
  3. Cả hai vị trí dài và ngắn đều có rủi ro mất mát

Hướng dẫn tối ưu hóa

  1. Tối ưu hóa các thông số Bollinger Bands để tìm kết hợp tốt nhất
  2. Thêm các chỉ số khác để lọc tín hiệu đột phá sai
  3. Tăng các chiến lược dừng lỗ để giảm lỗ đơn

Tóm lại

Chiến lược này kết hợp các đường trục Camarilla và Bollinger Bands, tạo ra các tín hiệu giao dịch khi giá phá vỡ mức hỗ trợ và kháng cự chính. Lợi nhuận và sự ổn định của chiến lược có thể được cải thiện thông qua tối ưu hóa tham số và lọc tín hiệu. Nhìn chung, chiến lược này có logic giao dịch rõ ràng và khả năng hoạt động cao, đáng để xác minh giao dịch trực tiếp.


/*backtest
start: 2024-01-28 00:00:00
end: 2024-02-04 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 12/05/2020
// Camarilla pivot point formula is the refined form of existing classic pivot point formula. 
// The Camarilla method was developed by Nick Stott who was a very successful bond trader. 
// What makes it better is the use of Fibonacci numbers in calculation of levels.
//
// Camarilla equations are used to calculate intraday support and resistance levels using 
// the previous days volatility spread. Camarilla equations take previous day’s high, low and 
// close as input and generates 8 levels of intraday support and resistance based on pivot points. 
// There are 4 levels above pivot point and 4 levels below pivot points. The most important levels 
// are L3 L4 and H3 H4. H3 and L3 are the levels to go against the trend with stop loss around H4 or L4 . 
// While L4 and H4 are considered as breakout levels when these levels are breached its time to 
// trade with the trend.
//
// WARNING:
//  - For purpose educate only
//  - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Camarilla Pivot Points V2 Backtest", shorttitle="CPP V2", overlay = true)
res = input(title="Resolution", type=input.resolution, defval="D")
width = input(1, minval=1)
SellFrom = input(title="Sell from ", defval="R1", options=["R1", "R2", "R3", "R4"])
BuyFrom = input(title="Buu from ", defval="S1", options=["S1", "S2", "S3", "S4"])
reverse = input(false, title="Trade reverse")
xHigh  = security(syminfo.tickerid,res, high)
xLow   = security(syminfo.tickerid,res, low)
xClose = security(syminfo.tickerid,res, close)
H4 = (0.55*(xHigh-xLow)) + xClose
H3 = (0.275*(xHigh-xLow)) + xClose
H2 = (0.183*(xHigh-xLow)) + xClose
H1 = (0.0916*(xHigh-xLow)) + xClose
L1 = xClose - (0.0916*(xHigh-xLow))
L2 = xClose - (0.183*(xHigh-xLow))
L3 = xClose - (0.275*(xHigh-xLow))
L4 = xClose - (0.55*(xHigh-xLow))
pos = 0
S = iff(BuyFrom == "S1", H1, 
      iff(BuyFrom == "S2", H2,
       iff(BuyFrom == "S3", H3,
         iff(BuyFrom == "S4", H4,0))))
B = iff(SellFrom == "R1", L1, 
      iff(SellFrom == "R2", L2,
       iff(SellFrom == "R3", L3,
         iff(SellFrom == "R4", L4,0))))
pos := iff(close > B, 1,
       iff(close < S, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )

Thêm nữa