버전 2,
여기서는 가격과 부피 정보를 보는 독특한 방법이 있습니다.
H = -sum(prob(i) * log_base2(prob(i)))
저는 분량 정보와 가격 정보의 차이점을 실험하는 전형적인 방법을 포함했습니다. 양쪽 값의
이 스크립트를 사용하는 것은
/*backtest start: 2022-04-22 00:00:00 end: 2022-05-21 23:59:00 period: 2h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © kocurekc //@version=4 // // @author Kocurekc // Rev-3, Added STDev bands and Precent Rank // Rev-2, Shannon entropy // Rev-1, new picture for moderators // Rev-0, added colors, flipped delta to clean up view // // Live a little, publish your scripts...be a John Elhers // study(title="Shannon Entropy V2", shorttitle="Info-S", precision=2) src = input(close, title="source", type=input.source) len = input(9, title="Entropy Length", type=input.integer) range = input(0.025, title="color level", type=input.float) avg = input(44, title="Averaging Length", type=input.integer) vPR = input(2, title="Percent Rank Limit", type=input.integer) bc = input(true, title="Include Source", type=input.bool) vc = input(true, title="Include Volume", type=input.bool) pb = input(true, title="Print Bands", type=input.bool) //Shannon Entropy, for source (close) or for Volume or both cr = src/sum(src,len) vr = log(volume)/sum(log(volume),len) info = ((vc ? sum(vr*log10(vr)/log10(2),len) : 0) - (bc ? vc ? sum(cr*log10(cr)/log10(2),len) : sum(cr*log10(cr)/log10(2),len) : 0)) //coloring for Shannon Entropy using both source and volume hc1 = info > range ? #4caf50 : info > range * -1 ? #ffeb3b : info <= range * -1 ? #f44336 : na //Plotting plot(info, style=(bc and vc ? plot.style_columns :plot.style_line ), color=hc1 ) plot((bc and vc ? 0 : na), color=color.gray) //Top/Bottom STDev value = wma(info,avg) top = value+stdev(info,len) btm = value-stdev(info,len) plot(pb ? top:na) plot(pb ? btm:na) //Percent Rank and ploting hvp = percentrank(info,avg) plotshape(hvp>(100-vPR) ? info : na, location=location.absolute, style=shape.triangledown, color=color.red, size=size.tiny, transp=30, offset=0) plotshape(hvp<vPR ? info : na, location=location.absolute, style=shape.triangleup, color=color.green, size=size.tiny, transp=30, offset=0) if hvp<vPR strategy.entry("Enter Long", strategy.long) else if hvp>(100-vPR) strategy.entry("Enter Short", strategy.short)