pine-script - Pinescript 基本问题:每天在设定的时间进行交易
问题描述
我想创建一个 Pinescript 策略,每天在东部时间下午 6 点开始交易。SL:2xATR。TP:2x 止损。
如果酒吧的收盘时间是东部时间下午 6 点,我正在努力将布尔变量设置为 TRUE。
我(显然)对 Pinescript 很陌生,希望能提供任何帮助。
最好的,
——克里斯
解决方案
这可以通过 time() 函数实现。您可以传递所需的必要会话并创建一个仅在会话开始时输入的条件。这是代码:
//@version=4
study("buy-first-bar-session", overlay=true)
sessionTime = input("1800-1800", "Session Time", type=input.session)
t = time("D", sessionTime) // 1440=60*24 is the number of minutes in a whole day. You may use "0930-1600" as second session parameter
is_first = na(t[1]) and not na(t) or t[1] < t
bgcolor(t ? color.blue : na)
plotshape(is_first, "Buy", style=shape.labelup, location=location.belowbar, textcolor=color.white, color=color.green, text="Buy")
推荐阅读
- python - Plotly Choropleth 地图在 Jupyter 中成功加载,但不是 Dash 浏览器
- javascript - 为什么要把赋值语句放在括号中?
- selenium - 如何在量角器中处理 shadow DOM 中的元素?deepcss 不工作
- ruby-on-rails - Ruby on Rails Cloudinary 错误:“Cloudinary”缺少服务适配器
- c# - 操纵杆坐标
- c# - SQLite 日历周开始
- css - 为什么我不能在 Ruby on Rails 中不使用 !important 来更改 link_to 文本颜色?
- spring - 无法获取查询元数据 org.postgresql.util.PSQLException 的连接:连接尝试失败
- elixir - Elixir Mix 版本 - 如何将额外文件复制到 Phoenix 应用程序的压缩包中?
- php - 如何在laravel中foreach第二张表后使用联合