投资者咨询:请老师帮忙编一下文华的代码 (文华财经WH8赢智V8.2)
来源:文华财经 日期:2018-7-4 19:31
Params
Bool bInitStatus(False); //初始化标志,修改初始仓位时设置为True
Numeric InitMyrealmp(0); //初始当前仓位,正数表示多单,负数表示空单
Numeric FirstGrid(30);//第一笔交易的间距,最小跳动
Numeric AddGrid(5);//加仓间距,最小跳动
Numeric totalGrids(10);//最大交易次数
Numeric TrailingGrid(30);//移动止损间距,最小跳动
Numeric EveryLots(1);//每次开仓手数
Numeric OffSet(1);//委托价偏差
Numeric ExitOnCloseMins(14.55);//收盘平仓时间
Vars
Numeric HighAfterLongEntry;
Numeric LowAfterShortEntry;
Numeric MyRealMp(0);
Numeric MinPoint;
Numeric TmpPrice;
Numeric TmpLots;
Begin
MinPoint=MinMove*PriceScale;
MyRealMp=GetGlobalVar(0);
HighAfterLongEntry=GetGlobalVar(1);
LowAfterShortEntry=GetGlobalVar(2);
If(BarStatus==0 And (MyRealMp==InvalidNumeric||bInitStatus))
{
MyRealMp=InitMyrealmp;
}
If(Date<>Date[1])
{
HighAfterLongEntry=High;
LowAfterShortEntry=low;
MyRealMp=0;
}
Else
{
HighAfterLongEntry=Max(HighAfterLongEntry,High);
LowAfterShortEntry=Min(LowAfterShortEntry,Low);
}
If(Time<ExitOnCloseMins/100)
{If(MyRealMp>0 and HighAfterLongEntry-low>=TrailingGrid*MinPoint And
(High-Low<TrailingGrid*MinPoint Or (high-Low>=TrailingGrid*MinPoint And close<Open)))
{
TmpPrice=Max(HighAfterLongEntry-TrailingGrid*MinPoint-OffSet*minpoint,Low);
TmpLots=Abs(MyRealMp*EveryLots);
Sell(TmpLots,TmpPrice);
MyRealMp=0;
LowAfterShortEntry=0;
}
Else
If(MyRealMp<0 And high-LowAfterShortEntry>=TrailingGrid*MinPoint And (high-low<TrailingGrid*MinPoint Or(high-Low>=TrailingGrid*MinPoint And Close>Open)))
{
TmpPrice=Min(LowAfterShortEntry+(TrailingGrid+OffSet)*MinPoint,High);
TmpLots=Abs(MyRealMp*EveryLots);
BuyToCover(TmpLots,TmpPrice);
MyRealMp=0;
HighAfterLongEntry=0;
}
If(MyRealMp==0 And High-LowAfterShortEntry>=FirstGrid*minpoint)//第一笔多单开仓
{
TmpPrice=Min(LowAfterShortEntry+(FirstGrid+OffSet)*minpoint,high);
TmpLots=EveryLots;
Buy(TmpLots,TmpPrice);
MyRealMp=1;
HighAfterLongEntry=high;
}
Else
If(MyRealMp>0 And MyRealMp<totalGrids And high-LowAfterShortEntry>=(FirstGrid+MyRealMp*AddGrid)*minpoint)//多单加仓
{
TmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*minpoint,High);
TmpLots=EveryLots;
Buy(TmpLots,TmpPrice);
MyRealMp=MyRealMp+1;
}
Else
If(MyRealMp==0 and HighAfterLongEntry-Low>=FirstGrid*minpoint)//第一笔空单 开仓
{
TmpPrice=Max(HighAfterLongEntry-(FirstGrid+OffSet)*minpoint,Low);
TmpLots=EveryLots;
SellShort(TmpLots,TmpPrice);
MyRealMp=-1;
LowAfterShortEntry=low;
}
Else
If(MyRealMp<0 and -1*MyRealMp<totalGrids And HighAfterLongEntry-Low>=(FirstGrid+Abs(MyRealMp*AddGrid))*minpoint)
{
TmpPrice=Max(HighAfterLongEntry-(FirstGrid+Abs(MyRealMp*AddGrid)+OffSet)*minpoint,Low);
TmpLots=EveryLots;
SellShort(TmpLots,TmpPrice);
MyRealMp=MyRealMp-1;
}
}
If(Time>=ExitOnCloseMins/100)
{
If(MyRealMp>0){
TmpLots=Abs(MyRealMp*EveryLots);
TmpPrice=close;
Sell(TmpLots,TmpPrice);
MyRealMp=0;
}
If(MyRealMp<0)
{
TmpLots=Abs(MyRealMp*EveryLots);
TmpPrice=close;
BuyToCover(TmpLots,TmpPrice);
MyRealMp=0;
}
}
SetGlobalVar(0,MyRealMp);
SetGlobalVar(1,HighAfterLongEntry);
SetGlobalVar(2,LowAfterShortEntry);
End
技术人员回复
日期:2018-7-4 19:36
1楼源码与文华MQ的宽语言相近
投资者咨询:请老师帮忙编一下文华的代码 (文华财经WH8赢智V8.2)
来源:文华财经 日期:2018-7-4 19:31
不能改写成文华8的源码么?
技术人员回复
日期:2018-7-4 19:46