- 精华
- 0
- 在线时间
- 91 小时
- UID
- 6686
- 积分
- 420
- 帖子
- 111
- 阅读权限
- 50
- 注册时间
- 2010-1-16
- 最后登录
- 2019-3-24
- 精华
- 0
- UID
- 6686
- 积分
- 420
- 帖子
- 111
- 主题
- 25
- 阅读权限
- 50
- 注册时间
- 2010-1-16
- 最后登录
- 2019-3-24
|
软件里面有啊
加仓减仓
本例仅以做多为例,做空类似。模板以首次开仓2手后每赢利30跳加仓一次,每次1手,最多加仓3次;开仓后每亏损30跳减仓1手。也可以转换为开仓价格的百分比值,或波动率的百分比等其任何设置的变量进行处理。
Vars
Numeric MinPoint; // 一个最小变动单位,也就是一跳
NumericSeries firstPrice; // 第一次开仓价格
NumericSeries LastPrice; // 最后一次开仓价格
Numeric AddSet(30); // 加仓设置
Numeric SubSet(30); // 减仓设置
Bool FirstEntryCon; // 首次开仓条件
Begin
FirstEntryCon = ...
MinPoint = MinMove*PriceScale;
If(MarketPosition==0)
{
If(FirstEntryCon)
{
firstPrice = Open;
LastPrice = firstPrice;
Buy(2,firstPrice);
}
}else If(MarketPosition==1) // 有多仓的情况
{
While(CurrentEntries < 4 && High >= LastPrice + AddSet*MinPoint) // 加仓
{
LastPrice = LastPrice + AddSet*MinPoint;
if(Open > LastPrice) LastPrice = Open;
Buy(1,LastPrice);
}
While(CurrentEntries > 0 && Low <= firstPrice - SubSet*MinPoint) // 减仓
{
firstPrice = firstPrice - SubSet*MinPoint;
if(Open < firstPrice) firstPrice = Open;
Sell(1,firstPrice);
}
}
...
End
|
|