Pine script 自交易进入后的尾随止损百分比

Pine script 自交易进入后的尾随止损百分比,pine-script,Pine Script,我正试图写一篇文章。该代码的设计目的是在进入后的前一个条数上达到最高 longStopPrice=0.0,shortStopPrice=0.0,lengthinmp=0,highesthigh=0.0,stopValue=0.0 longStopPrice:=if(strategy.position\u size>0) lengthinmp:=barssince(strategy.position\u size==0) highesthigh=high(high,barssince(strate

我正试图写一篇文章。该代码的设计目的是在进入后的前一个条数上达到最高

longStopPrice=0.0,shortStopPrice=0.0,lengthinmp=0,highesthigh=0.0,stopValue=0.0

longStopPrice:=if(strategy.position\u size>0) lengthinmp:=barssince(strategy.position\u size==0)
highesthigh=high(high,barssince(strategy.position_size==0))//在此行的早期版本中使用了lengthinmp stopValue=最高值*(1-StopERC) //最大值(stopValue,longStopPrice[1]) 其他的 0

我得到的错误是 第49行:无法使用参数调用“highest”(系列[float],系列[integer]);可用重载:最高(系列[float],整数)=>系列[float];最高(整数)=>系列[浮点]


我的理解是,当工作时,它将不包括当前的酒吧。有人知道如何包含当前的条吗?谢谢

以下是跟踪最高点和最低点的示例:

// 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)

longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)

var float hh = na
hh := strategy.position_size > 0 ? max(nz(hh), high) : na
plot(hh, style = plot.style_linebr, color = color.blue)

var float ll = na
ll := strategy.position_size < 0 ? min(na(ll) ? low : ll, low) : na
plot(ll, style = plot.style_linebr, color = color.red)
//此源代码受Mozilla公共许可证2.0的条款约束,位于https://mozilla.org/MPL/2.0/
//©阿道尔政府
//@版本=4
策略(“我的策略”,overlay=true)
长条件=交叉(sma(闭合,14),sma(闭合,28))
如果(长期条件)
strategy.entry(“我的长输入Id”,strategy.Long)
短条件=交叉(sma(闭合,14),sma(闭合,28))
if(短条件)
strategy.entry(“我的短输入Id”,strategy.Short)
var float hh=na
hh:=策略。位置大小>0?最大值(新西兰(高),高):不适用
绘图(hh,style=plot.style\u linebr,color=color.blue)
var float ll=na
LH:=策略。位置\大小<0?最小值(na(ll)?低:ll,低:na
绘图(ll,style=plot.style\u linebr,color=color.red)

错误的原因是传递给
最高
函数的序列
长度
。有
input int/float
type expected。如果在策略中使用了代码,是否有方法将其集成到当前条形图中?