本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=4
study("CICO Report")
// Cash in/cash out report (CICO). Brought to you by Johnny Nickles via Trading View Pine script. If you find this helpful in anyway, please leave a like!
// You may also find the Cashflow and Position calculator tools helpful as well. Both are free to use on the Trading View public indicators
// This indicator was built with the intent to quiet the market noise. The CICO Report takes the average price of a given time period (each candle) and
// multiples by the current volume. Then the indicators gives a running sum of the up and down movements of a market. When the sum is positive, green; negative, red.
// The area portion of the indicator is the sum and the column bar is the current cash in or cash out.
// The CICO Report will also color your chart with the running sum. I recommend matching a moving average to the market you are watching for best results.
// Next, enter the moving average value into the CICO Report input. Once matched, the moving average and the running sum should make sense visually.
// userLen is the user input value for desired length of time
userLen = input(defval=100, type=input.integer, title='User length', minval=0)
// cashVec is the price going up or down
cashVec = close - open
// cashMag will take the average price between high and low and multiple by the current volume, value is negative when price is going down.
cashMag = cashVec > 0? volume * ((high + low) / 2): cashVec < 0? -1 * (volume * ((high + low) / 2)): na
// cashSum takes the sum of the cashMag values based on user input length (the moving average of the market)
cashSum = sum(cashMag, userLen)
// This plotting makes the indicator look pretty. Can be customized here or in the front panel.
plot(cashMag, title='Cash in/Cash out', style=plot.style_columns, color=cashVec > 0? color.green : color.red)
plot(cashSum, title='Running sum', style=plot.style_area, color = cashSum > 0? color.green: color.red, transp = 75)
// This is what colors the chart. I recommend setting your current colors to all grey frist. Basically this is coloring the bars green if the sum, current and vector are all moving in the same direction.
// Bar coloring can be turned off in the front panel.
barcolor(title='Bar coloring', color= cashVec > 0 and cashSum > 0 and cashMag > 0? color.green: cashVec < 0 and cashSum < 0 and cashMag < 0? color.red: na)
// Proper risk management is the key to the stock market. I hope this tool makes you a lot of money!