[英]Pine Script / Trading View - Calculating Trading Day of Month (TDOM)
I want to calculate the Trading Day of the Month in (TDOM) in TradingView/Pine Script.我想在 TradingView/Pine 脚本中计算 (TDOM) 中的每月交易日。
I tried the following, but it didn't work:我尝试了以下方法,但没有奏效:
int counter = 0
if (month != month[1])
counter := 0
if (dayofmonth != dayofmonth[1])
counter := counter + 1
plot(counter)
Any thoughts/help on how I can get TDOM?关于如何获得 TDOM 的任何想法/帮助?
You have to use the var
keyword, or else your counter
will be reset to 0 at every bar.您必须使用var
关键字,否则您的counter
将在每个柱上重置为 0。
//@version=5
indicator("My Script")
var int counter = 0
if ta.change(month)
counter := 0
if ta.change(dayofmonth)
counter += 1
plot(counter)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.