//------------------------------------------------------------------------
// 简称: ProfitTrackExit
// 名称: 盈利跟踪平仓
// 类别: 用户函数
// 类型: 内建函数
// 输出: 布尔型
//------------------------------------------------------------------------
Params
//此处添加参数
Integer profitoffsetMethod;
Numeric profitOffset;
Integer exitOffsetMethod;
Numeric exitOffset;
Vars
//此处添加变量
Series<Numeric> highestPrice(-1, 2);
Begin
//此处添加代码正文
if(!StopProfit(profitoffsetMethod,profitOffset))
{
highestPrice = -1;
Return false;
}
//此处添加代码正文
If(MarketPosition == 0 or BarsSinceLastEntry == 0)//当前Bar有开仓不平仓
{
highestPrice = -1;
Return false;
}
Else If(MarketPosition > 0)
{
if(highestPrice == -1)
{
if(BarsSinceLastEntry == 1)
{
highestPrice = LastEntryPrice;
}
Else
{
highestPrice = High[1];
}
}
Else
{
highestPrice = max(highestPrice,High[1]);
}
If(exitOffsetMethod == Enum_Offset_ByJump)
{
Return Low <= OffsetByJump(highestPrice, -exitOffset);
}
Else If(exitOffsetMethod == Enum_Offset_ByPercent)
{
Return Low <= OffsetByPercent(highestPrice, -exitOffset);
}
}
Else
{
if(highestPrice == -1)
{
if(BarsSinceLastEntry == 1)
{
highestPrice = LastEntryPrice;
}
Else
{
highestPrice = low[1];
}
}
Else
{
highestPrice = min(highestPrice,low[1]);
}
If(exitOffsetMethod == Enum_Offset_ByJump)
{
Return High >= OffsetByJump(highestPrice, exitOffset);
}
Else If(exitOffsetMethod == Enum_Offset_ByPercent)
{
Return High >= OffsetByPercent(highestPrice, exitOffset);
}
}
Return False;
End
//------------------------------------------------------------------------
// 简称: TrackExit
// 名称: 跟踪平仓
// 类别: 用户函数
// 类型: 内建函数
// 输出: 布尔型
//------------------------------------------------------------------------
Params
//此处添加参数
Integer offsetMethod;
Numeric offset;
Vars
//此处添加变量
Series<Numeric> highestPrice(-1, 2);
Begin
//此处添加代码正文
If(MarketPosition == 0 or BarsSinceLastEntry == 0)//当前Bar有开仓不平仓
{
highestPrice = -1;
Return false;
}
Else If(MarketPosition > 0)
{
if(highestPrice == -1)
{
highestPrice = LastEntryPrice;
}
Else
{
highestPrice = max(highestPrice,High[1]);
}
If(offsetMethod == Enum_Offset_ByJump)
{
Return Low <= OffsetByJump(highestPrice, -offset);
}
Else If(offsetMethod == Enum_Offset_ByPercent)
{
Return Low <= OffsetByPercent(highestPrice, -offset);
}
}
Else
{
if(highestPrice == -1)
{
highestPrice = LastEntryPrice;
}
Else
{
highestPrice = min(highestPrice,low[1]);
}
If(offsetMethod == Enum_Offset_ByJump)
{
Return High >= OffsetByJump(highestPrice, offset);
}
Else If(offsetMethod == Enum_Offset_ByPercent)
{
Return High >= OffsetByPercent(highestPrice, offset);
}
}
Return False;
End
//------------------------------------------------------------------------
// 编译版本 2019/11/20 111646
// 版权所有 riv
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// 编译版本 2019/11/20 133942
// 版权所有 riv
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------