对于大家很感兴趣的「ahr999 定投指数」,我把代码分享在此,希望对你有所帮助。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © davidfnck
//@version=4
study("囤比特币:ahr999定投指数", shorttitle="ahr999指数-囤比特币", overlay=false)
birth_day = '2009-01-03'
coin_age = (round(time_close/1000) - 1230912000)/(60*60*24)
coin_price = pow(10,5.84*log10(coin_age)-17.01)
// plot(coin_price, linewidth=3, color=color.red)
//200天定投成本,还是要用几何平均
price = input(title ="Source", defval=close)
per = input(title="Length",defval=200)
lmean = log(price)
smean = sum(lmean,per)
gma = exp(smean/per)
// plot(gma,title="GMA",linewidth=5, color=color.green)
// 指数
index = (close/coin_price)*(close/gma)
plot(index,title="ahr999_index",linewidth=5, color=color.blue)
// 定投区间绘制
h1 = hline(0.45,title='抄底区间',linewidth=2)
h2 = hline(1.2,title='定投区间',linewidth=2)
fill(h1, h2,color=color.red)
dt = time - time[1]
if barstate.islast
label1 = label.new(time + 400*dt,1.20,text='定投基准线:1.2', xloc=xloc.bar_time)
label2 = label.new(time + 400*dt,0.45,text='梭哈基准线:0.45', xloc=xloc.bar_time)
label4 = label.new(time + 200*dt,0.7,text='定投区间', xloc=xloc.bar_time)
label5 = label.new(time + 200*dt,3.0,text='囤住区间', xloc=xloc.bar_time)
label6 = label.new(time + 200*dt,0.05,text='梭哈区间', xloc=xloc.bar_time)
label.set_style(label1, label.style_labeldown)
label.set_style(label2, label.style_labeldown)
label.set_style(label4, label.style_none)
label.set_textcolor(label4, color.red)
label.set_style(label5, label.style_none)
label.set_textcolor(label5, color.red)
label.set_style(label6, label.style_none)
label.set_textcolor(label6, color.red)
label.set_color(label1, color.black)
label.set_textcolor(label1, color.lime)
label.set_color(label2, color.black)
label.set_textcolor(label2, color.lime)
if 0.45<index and index<=1.2
label3 = label.new(time,index+0.05,text='当前指数:' + tostring(index) + '\n 适合定投',xloc=xloc.bar_time)
label.set_color(label3, color.green)
label.set_textcolor(label3, color.white)
if index<=0.45
label3 = label.new(time,index+0.05,text='当前指数:' + tostring(index) + '\n 适合梭哈',xloc=xloc.bar_time)
label.set_color(label3, color.red)
label.set_textcolor(label3, color.white)
if index>1.2
label3 = label.new(time,index+0.05,text='当前指数:' + tostring(index) + '\n 适合囤住',xloc=xloc.bar_time)
label.set_color(label3, color.orange)
label.set_textcolor(label3, color.white)
// 增加区间绘图
if index < 0.45
index
内容搜集自网络,整理者:BTCover,如若侵权请联系站长,会尽快删除。