【问题标题】:Need help - how to ignore specific dates for my strategy需要帮助 - 如何忽略我的策略的特定日期
【发布时间】:2023-02-08 00:32:00
【问题描述】:
我正在为我的策略寻找解决方案。
我想排除在特定日期发生的交易。
例如。我不想在出现极端新闻(例如 CPI、非农就业人数)的日子进行交易。那么有没有一种方法可以说:
没有交易(例如)03.02.2023、XX.XX.XXXX 等。
换句话说——我可以说,只在特定日期进行交易吗?例如2023 年 2 月 3 日?
提前致谢!
【问题讨论】:
标签:
pine-script
pine-script-v5
trading
algorithmic-trading
【解决方案1】:
您可以使用内置变量 year、month 和 dayofmonth 查看具体日期。
使用这三个来确定您是否想交易这一天。使用 not 运算符将其添加到您的输入条件。
no_trade_day_1 = (year == 2023) and (month == 2) and (dayofmonth == 3) // 03.02.2023
trade_cond = (your_trade_cond) and not no_trade_day_1 // Trade if you have a valid signal and if it is NOT 03.02.2023