pine-script - 强制策略仅在蜡烛收盘时进入交易
问题描述
在实际交易中,如何强制策略仅在蜡烛收盘时或蜡烛结束前的最后 5 秒内进行交易?添加什么条件或做什么?
解决方案
尝试这个:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © adolgov
//@version=4
strategy("My Strategy", overlay=true, margin_long=100, margin_short=100, calc_on_every_tick=true)
// some random entry
if barstate.islast and strategy.position_size==0 and strategy.closedtrades == 0
strategy.entry("My Long Entry Id", strategy.long)
if time_close - timenow <= 5*1000
strategy.close_all()
推荐阅读
- spring-boot - Spring Boot中带有过滤器的会话超时
- c++ - OUTPUT ERROR,问题是求和5000位数字cpp
- python - 使具有不同采样率的两个时间序列具有可比性
- acumatica - 发布自定义:无法合并文档;发现重复对象:验证失败
- python - 在 python [on linux, Ubuntu 20.04] 中从 OS 模块打开一个文件
- python - Python 包错误的 setup.py 文件中的 install_requires
- python - 如何使用 python 代码在单个图像上裁剪连续圆形区域
- c# - 当我更新安全标记时,网页永远不会结束加载
- reactjs - ReactJS:从本地存储令牌获取数据时超出了最大更新深度
- python - mpi4py 不允许我使用 dtype = object 发送和接收数组