小智 1
如果您想计算特定时间段内的柱数,那么以下是 pine 脚本:
\n// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/\n// \xc2\xa9 PHStudios\n\n//@version=4\nstudy("Candle Counter", shorttitle="CCount", overlay=true)\n\ntimeYear = input(2021, title="Year", minval=1991, maxval=2100, type=input.integer)\ntimeMonth = input(6, title="Month", minval=1, maxval=12, type=input.integer)\ntimeDay = input(21, title="Day", minval=1, maxval=31, type=input.integer)\ntimeHours = input(9, title="Hours", minval=0, maxval=23, type=input.integer)\ntimeMinutes = input(15, title="Minutes", minval=0, maxval=59, type=input.integer)\ntimeSeconds = input(0, title="Seconds", minval=0, maxval=59, type=input.integer)\n\n// Initilization of variables only once\nvar greenCandleCount = 0 \nvar redCandleCount = 0\nvar totalCandleCount = 0\n\n// Reset Candle Count to 0 from a particular time interval\nif(year == timeYear and month == timeMonth and dayofmonth == timeDay and hour == timeHours and minute == timeMinutes and second == timeSeconds)\n greenCandleCount := 0\n redCandleCount := 0\n totalCandleCount := 0\n\n// Counting Total Number of Green, Red, and Sum of Both Candles\nif(close > open)\n greenCandleCount += 1\n totalCandleCount += 1\n\nif(open > close)\n redCandleCount += 1\n totalCandleCount += 1\n\nplotchar(greenCandleCount, title="Green Bars", color=color.green, char='')\nplotchar(redCandleCount, title="Red Bars", color=color.red, char='')\nplotchar(totalCandleCount, title="Total Bars", color=color.black, char='')\nRun Code Online (Sandbox Code Playgroud)\n只需选择您想要计算柱形的确切日期和时间,即可将输出绘制在图表上。
\n| 归档时间: |
|
| 查看次数: |
7270 次 |
| 最近记录: |