pine-script - 在 pine 脚本版本 2 中使用标志概念
问题描述
我必须使用 pine 脚本的版本 2,因为使用版本 4 的结果与版本 2 不同。我希望在脚本中使用标志的概念,即我希望一个变量在满足条件后立即取值 1在未满足退出条件时进行交易并保持 1。我正在尝试使用下面的代码
var putflag := 0 //declaring the flag for taking a short position
trend = cola == red ? 0 : 1
put = putflag ==0 and trend ==0 and (open > out1 or high >= floor(out1 - 5)) //conditions for taking the short position
if put ==1
putflag :=1 // the flag takes value at the first instance trade conditions are met and stays 1 till exit conditions are not met.***
但是这在版本 2 中没有执行,而在版本 4 中这很容易完成
解决方案
推荐阅读
- android - 将本机上传图像反应到 api 得到网络错误
- prolog - 定义一个关系 first_last(L1, L2),它接受一个列表 L1 并返回一个包含 L1 的前三个和后三个元素的列表 L2
- javascript - API正在使用CORS,如何在vue中使用axios?
- javascript - 按列过滤数据表以获取范围内的结果(单击按钮)
- android-studio - 如何在 ARCore 中显示 .obj
- javascript - 如何使用引导程序创建可折叠菜单
- javascript - 单击按钮时需要帮助播放音频文件(反应)
- f# - 如何解析日期和选项日期?
- algorithm - 具有附加约束的最小成本问题
- python - 遍历坐标列表?