如何自动更改输入。TimeFrame(TimeFrame(d')到比用户图表大的周期。 Pinescript V5
我是新手。我有一个Pine脚本代码。
功能问题:
input.timeframe('D')
我需要脚本来调用比实时使用的脚本时间高的资产公式时间。
我使用一个函数:
request.security()
带有Mutable变量的错误调用字符串:
input.timeframe(VAR)
返回错误:
An argument of 'simple string' type was used but a 'const string' is expected.
呼叫带有时间范围的资产与真实用户时间范围不同。
当我使用小时时间表时。 指示器函数应调用上层时间IE ='d'。
或
当实时是“ D”时。指示器功能应调用上班时间IE周='W'。
我想要自动搜索功能。
并且用户以可选方式手动选择时间范围。
代码示例如下:
//@version=5
indicator(title="My Indicator", shorttitle="My Indicator", overlay=true, timeframe="", timeframe_gaps=true)
timeframe_automatic = (timeframe.isintraday ? 'D' : timeframe.isdaily ? 'W' : timeframe.isweekly ? 'M' : na)
timeframe_options = input.timeframe((timeframe_automatic), "Resolution Big", options=['D', 'W', 'M'])
timeframe_called = (request.security(syminfo.tickerid, (timeframe_options), close, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off))
Pine脚本编译器需要输入的“字符串const”。TimeFrame('d')以及“ D”。
并在使用可突出的“简单字符串”进行自动搜索时拒绝。:
line xxx: Cannot call 'input.timeframe' with argument 'defval'='timeframe_options'. An argument of 'simple string' type was used but a 'const string' is expected.
我找不到文档中适用于此的正确功能。
感谢您的帮助。
I'm newbie. I have a Pine script code.
Problem with function:
input.timeframe('D')
I need the script to call an asset formula time higher than the one used in real time.
I use a function:
request.security()
Error calling string with mutable variable:
input.timeframe(VAR)
Return error:
An argument of 'simple string' type was used but a 'const string' is expected.
To call up an asset with timeframe different from the real user timeframe.
When I use the HOURS time chart.
The indicator function should call the upper time ie days = 'D' .
Or
When real time is 'D'. The indicator function should call the upper time ie week = 'W' .
I want Automatic Time Search function.
And also that the user chooses timeframe manually in an Optional way.
The code EXAMPLE is as follows:
//@version=5
indicator(title="My Indicator", shorttitle="My Indicator", overlay=true, timeframe="", timeframe_gaps=true)
timeframe_automatic = (timeframe.isintraday ? 'D' : timeframe.isdaily ? 'W' : timeframe.isweekly ? 'M' : na)
timeframe_options = input.timeframe((timeframe_automatic), "Resolution Big", options=['D', 'W', 'M'])
timeframe_called = (request.security(syminfo.tickerid, (timeframe_options), close, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off))
The Pine Script compiler requires a 'String Const' for input.timeframe('D') as well as 'D'.
And refuses when using a mutable 'Simple String' for automatic search.:
line xxx: Cannot call 'input.timeframe' with argument 'defval'='timeframe_options'. An argument of 'simple string' type was used but a 'const string' is expected.
I can't find proper functions in the documentation to work around this.
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你已经拥有了。在您的安全调用中使用
timeframe_automatic
。You already have it. Use
timeframe_automatic
in your security call.问题是要使用户决定将其置于自动模式或将其置于手动模式之间。
和
input.TimeFrame(timeFrame_automatic)
不接受可变变量,而只是const字符串。但是,
request.security()
接受周期可变变量,要求其为const字符串。我发现的解决方案是将决策分为3个不同的代码。
我必须添加手动选择器的第一代码才能在自动或手动代码之间进行选择。
以及制定决策的第二代码。
最后,第三代码进行了函数调用。
代码看起来像这样,示例:
现在好!
The problem was to make the user decide between leaving it in automatic mode or putting it in manual mode.
And
input.timeframe(timeframe_automatic)
does not accept a mutable variable but just a const string.But,
request.security()
accepts period mutable variable with the requirement that it be const string.The solution I found was to separate the decisions into 3 different codes.
The 1st code I had to add a manual selector to select between Automatic or Manual code.
And a 2nd code for making decisions.
And finally, the 3rd code makes the function call.
The code looks like this, Example:
Ok now!