TradingView
Investorito
2017年2月22日晚上6點55分

Cumulative Tick 

NYSE CUMULATIVE TICKUSI

描述

This is a script that I use to plot the cumulative TICKS. It resets at the beginning of the session (or whatever time is entered on the input variable) and then starts adding, or subtracting if negative).

發布通知

This version actually does what was intended. The old version was full of bugs

發布通知

Updated color of bar will be in relation to Moving Average and not whether it is above or below 0.

Fixed Moving Average bug

發布通知

Change Log:
  • Updated to version 4 (from version 2)
  • changed code-base to one that works on version 4. Thanks to PineCoders-LucF!
  • Added a range for reset time
  • added label to measure the gap between a moving average and the cumulative tick


More Info:
- The gap between the moving average and the cumulative tick is an improvement over previous versions. I use this spot changes in sentiment to plan my entry/exit. If the market is trending and the gap starts getting narrower (closer to zero) then I may start taking a few contracts off my position. If I am trying to play a countertrend trade, I may use the gap to start planning my entry.

發布通知

Fixed Average Gap
評論
markkinch
Thank you for the script!
i have two questions: does "0930-1000" mean it calculates new tick cumulatives for only 9:30AM to 10AM? shouldn't it be "0930-1600"?
Thanks in advance.
Investorito
Here is the latest version.

Change Log:
- Bug fix: properly resets every day



//@version=2
study(title="Cumulative Tick",shorttitle="Cumulative Tick", precision=0, overlay=true)
src = input(close, title="Source")
upColor=green
downColor=red

is_newbar(res) =>
t = time(res)
cumVal = change(t) != 0 ? 0 : src + nz(cumVal [1],0)
myColor = is_newbar("0930") > 0 ? upColor : downColor
plot(is_newbar("0930"),title="Cumulative",color=myColor,linewidth=4, style=histogram)
bldgr
@bldgr, edit: add [1] to the cumVal on line 9.
bldgr
@bldgr, sigh, this comment section can't take ] and [ symbols.
Investorito
@bldgr, FYI, I am not sure why I missed this earlier this year.

checkout this link for a similar function written for v4.

stackoverflow.com/questions/60835651/how-to-create-cumulative-tick-using-pine-script-for-tradingview
Investorito
I just realized that there is a major flaw on this code. I guess my EasyLanguage skills didn't translate well to Pine.

Since I can't post a new version of the code, I am just posting the code above. Feel free to just copy paste into the PineEditor (use the help function and if you still have questions, please feel free to post here).

//@version=3
study(title="Cumulative Tick",shorttitle="CumTick", precision=0, overlay=false)
upColor=green
downColor=red

is_newbar(res) =>
t = time(res)
cumVal = change(t) != 0 ? 0 : close + nz(cumVal [1],0)
myColor = is_newbar("0930") > 0 ? upColor : downColor
plot(is_newbar("0930"),title="Cumulative",color=myColor,linewidth=4, style=histogram)
zeropaul
@Investorito, I'd love to try this V3 of your script, but it's producing errors that I can't resolve. Perhaps that's due to the Pine version changing since this code was written?
更多