Type/to search
0
Follow
0
Followers
Làm thế nào để có được đường trung bình động 30 ngày
Help
Created 2020-07-13 22:13:31  
 2
 1391

def get_records(value):
Log("get records day:",value)
records = exchange.GetRecords(PERIOD_D1)
res = 0
for i in range(-(value + 1),-1):
res = res + records[i]["Close"]
Log("time:", records[i]["Time"], "value:",records[i]["Close"])
return res/value

Sử dụng hàm này để tính đường trung bình
Trong thử nghiệm, không thể thiết lập chu kỳ k-line của ổ cứng là ngày, vì vậy độ dài của các bản ghi thường chỉ có 5,6 ngày, không thể có được đường trung bình 30 ngày, làm thế nào để giải quyết?

Related Recommendations
Comment
All comments (2)

    不是函数调用的问题
    在实盘中,返回的只有一天的数据,无法算5天均线,30天均线
    模拟盘返回的数据比较多,是够的
    模拟盘的k线数据和实盘的是不是一样的,如果是一样的,那可以用模拟盘的数据回测

    6 years ago

    GetRecords可以设置成任意周期,当然可以为天。你在哪里不能设置了?

    6 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)