“我正在做一个指标。我希望能够对其进行回测。”
“这是我已经尝试过的”
fromDay = input(defval= 1, title="fromDay",minval= 1, maxval= 31)
fromMonth = input(defval= 1, title="fromMonth",minval= 1, maxval= 12)
fromYear = input(defval= 1, title="fromYear",minval= 1017)
toDay = 1 //input(defval= 1, title="toDay",minval= 1, maxval= 31)
toMonth = 1 //input(defval= 1, title="toMonth",minval=1, maxval= 31)
toYear = 9999 //input(defval= 9999, title="toYear",minval= 9999)
Start = timestamp(fromDay , FromMonth , fromYear , 00 , 00) //start
of window
Finish = timestamp(toDay , toMonth , toYear , 00 , 00) //end
of window
Window() => time => Start and time <= Finish ? true : false //create
the function "within the window of time"
“这是我得到的错误信息。 输入=>时出现语法错误。我在Window()函数中遇到了错误”
答案 0 :(得分:0)
只需重复使用工作代码即可,您将在这里找到:http://www.pinecoders.com/faq_and_code/#how-do-i-implement-date-range-filtering-in-strategies
使用此功能时,它还为您提供了更大的灵活性。
如果您真的想使用代码,这是正确的语法:
//@version=4
study("My Script")
fromDay = input(defval= 1, title="fromDay",minval= 1, maxval= 31)
fromMonth = input(defval= 1, title="fromMonth",minval= 1, maxval= 12)
fromYear = input(defval= 1017, title="fromYear",minval= 1017)
toDay = 1 //input(defval= 1, title="toDay",minval= 1, maxval= 31)
toMonth = 1 //input(defval= 1, title="toMonth",minval=1, maxval= 31)
toYear = 9999 //input(defval= 9999, title="toYear",minval= 9999)
Start = timestamp(fromYear , fromMonth , fromDay , 00 , 00) //start of window
Finish = timestamp(toYear , toMonth , toDay , 00 , 00) //end of window
Window() => time >= Start and time <= Finish ? true : false //create the function "within the window of time"
plot(Window()?1:0)