【问题标题】:Pine Script Back testingPine 脚本回测
【发布时间】:2020-06-10 17:32:43
【问题描述】:

我正在编写一个简单的 pine 脚本,以在每小时蜡烛关闭 10 分钟前走长,并在蜡烛关闭后 10 分钟后短时关闭。

但该脚本不适用于以前的日期/时间,而仅适用于我将其添加到图表的时间。

我想对这个简单的策略进行回测。有人可以帮忙吗?

我对脚本非常陌生。感谢任何帮助。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jayaguru
//@version=4 
strategy("My Strategy", overlay=true)

longCondition = minute(timenow)

if (longCondition == 55)
    strategy.entry("Long", strategy.long, comment="Long")
if (longCondition == 14 or strategy.openprofit < -15 or strategy.openprofit > 40)
    strategy.close_all()

【问题讨论】:

    标签: scripting pine-script binance


    【解决方案1】:

    您正在使用timenow 变量,即当前日期/时间(如“现在”)。
    相反,您需要使用 time 来返回酒吧打开的时间。
    像这样:

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jayaguru
    //@version=4 
    strategy("My Strategy", overlay=true)
    
    longCondition = minute(time)
    
    if (longCondition == 55)
        strategy.entry("Long", strategy.long, comment="Long")
    if (longCondition == 14 or strategy.openprofit < -15 or strategy.openprofit > 40)
        strategy.close_all()
    

    更多信息请参见Access bar times programmatically in TradingView Pine

    【讨论】:

    • 非常感谢比约恩。感谢你的帮助。如果以下陈述有误,请您帮忙。这没用。我试图保持这个位置,直到它达到净亏损或利润,但似乎不起作用。 if (longCondition == 14 or strategy.netprofit 60) strategy.close_all()
    猜你喜欢
    • 2021-11-18
    • 2022-08-12
    • 2021-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多