- 精华
- 0
- 在线时间
- 76 小时
- UID
- 240670
- 积分
- 23
- 帖子
- 17
- 阅读权限
- 10
- 注册时间
- 2016-9-20
- 最后登录
- 2022-1-7
- 精华
- 0
- UID
- 240670
- 积分
- 23
- 帖子
- 17
- 主题
- 4
- 阅读权限
- 10
- 注册时间
- 2016-9-20
- 最后登录
- 2022-1-7
|
新新手写了个公式,逻辑比较简单,就是记录开多仓后的最高价,现价回撤N跳后反手,开空单后记录最低价,当现价高于最低价N跳后在反手,代码如下请老师和小米版主帮忙修改 谢谢
Params
Numeric aa(15);
Vars
Numeric minpoint;//一跳
Numeric myentryprice;//开仓价 均价
Numeric myexitprice;//平仓价
NumericSeries highestafterentry;//开仓后出现的最高价
NumericSeries lowestafterentry;//开仓后出现的最低价
Begin
minpoint = MinMove * PriceScale;//最小变动1跳
myentryprice = AvgEntryPrice;//建仓价是当前平均建仓价
// 集合竞价过滤
If(BarStatus == 2 And IsCallAuctionTime) Return;
if (MarketPosition ==0 && open[1]-Close[1]>2)
{SellShort(1,Open);}
if (MarketPosition ==0 && Close[1]-Open[1]>2)//突破上根K线最高价N个价位
{Buy(1,Open);}
If(BarsSinceEntry ==0)
{highestafterentry = Close;
lowestafterentry = Close;
If(MarketPosition<>0 )
{highestafterentry = Max (highestafterentry,AvgEntryPrice );
lowestafterentry = Min (lowestafterentry ,AvgEntryPrice );
}}Else
{highestafterentry = Max (highestafterentry,high );
lowestafterentry = Min (lowestafterentry ,low );}
If (MarketPosition==-1 AND BarsSinceEntry >=1)
{If ( lowestafterentry - Close[1]<=-aa )
Buy(1,Open);
}
If (MarketPosition==1 AND BarsSinceEntry >=1)
{If (Close[1] - highestafterentry <=-aa )
SellShort(1,Open);
}
End
|
|