pine-script - 我想将多空策略转换为多头策略
问题描述
我怎样才能使这个策略只做多头,关闭多头头寸而不是做空?
非常感谢!
//Noro
//2019
//@version=3
strategy(title = "Noro's TrendTrader Strategy v1.0", shorttitle = "TT str", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
len = input(21, minval=1)
mult = input(3, minval=1)
//Line
atr = wma(atr(1), len)
highestC = highest(len)
lowestC = lowest(len)
hiLimit = highestC[1] - (atr[1] * mult)
loLimit = lowestC[1] + (atr[1] * mult)
ret = 0.0
ret := close > hiLimit and close > loLimit ? hiLimit : close < loLimit and close < hiLimit ? loLimit : nz(ret[1])
plot(ret, color= blue , title = "Trend Trader")
//Trading
if low > ret and close < open
strategy.entry("L", strategy.long)
if high < ret and close > open
strategy.entry("S", strategy.short)
解决方案
推荐阅读
- c++ - C++ - 如何调用递归继承的模板化基类的模板化方法
- android - 使用 Flutter 在 Playstore 上发布应用
- html - 如何在我自己的前端使用适当的样式表渲染来自 TinyMCE 的 HTML?
- javascript - Vue js:比较数组中的元素
- python - 我可以用命名参数作为变量在python中调用函数吗?
- r - R 字符串方法
- python - Pandas:如何在多级列选择和值设置中解释这种 .loc 行为
- python - 如何更新 miniconda 和 Spyder 4.2.1
- reactjs - 我的反应应用程序中的路由器引发错误
- php - PHPUnit 总是在每个测试方法中运行 setUpDatabase