- 精华
- 0
- 在线时间
- 65 小时
- UID
- 2282
- 积分
- 265
- 帖子
- 51
- 阅读权限
- 50
- 注册时间
- 2008-9-5
- 最后登录
- 2012-2-27
- 精华
- 0
- UID
- 2282
- 积分
- 265
- 帖子
- 51
- 主题
- 17
- 阅读权限
- 50
- 注册时间
- 2008-9-5
- 最后登录
- 2012-2-27
|
老大好!我自己学习编写了个日线系统交易程序,以指数图作为参考,当出现信号以当日收盘前手动输入相关商品的主力合约。想请教一下,如果我想将相关主力合约直接写进程序从而达到自动交易的目的,请问有几点需要注意!谢谢!
源程序:
Params
Numeric duo(5);
Numeric Kong(-5);
Numeric exitbar(10);
Vars
NumericSeries fen; //总分
Numeric zdf; //涨跌幅,阳线 +,阴线 -
Numeric st; //K线柱体,阳线+,阴线-
Numeric syx; //阳线上影线 -
Numeric xyx; //阳线下影线 +
Begin
if(close>open)//阳线
{
zdf=(close-close[1])/close[1]*100;
st=(close-open)/open*100;
syx=((close-high)/(close[1])*100);
xyx=(open-low)/(close[1])*100;
}Else
{
if(close<open)//阴线
{
zdf=(close-close[1])/close[1]*100;
st=(close-open)/open*100;
syx=(open-high)/(close[1])*100;
xyx=((close-low)/(close[1])*100);
}
}
fen=(st+zdf+syx+Xyx);
if(close>open)
{
if (fen>0 and fen>duo and duo<>0 and MarketPosition<>1)
{
buy(1,close);
}
}Else
{
if(close<open)
{
if(fen<0 and fen<Kong and Kong<>0 And MarketPosition<>-1)
{
SellShort(1,close);
}
}
}
////////////////////////////////////////平仓///////////////////////////////////////////////////
IF (BarsSinceEntry==exitbar)
{
Commentary("日期出场");
Sell(0,Close);
BuyToCover(0,close);
}
End |
|