问个函数BUY的问题: 如果当前持仓状态为空仓,即MarketPosition = -1 时,该函数首先平掉所有空仓,达到持平的状态,然后再按照参数进行多头建仓。 如果我要将原来的4手空单变为2手空单,我可以用什么函数?
新建一个技术指标,比如MyAverage,代码如下: //------------------------------------------------------------------------ // 简称: AveragePrice // 名称: 我的分钟均线 // 类别: 技术指标 // 类型: 移动平均类 // 输出: 一条指标线 //------------------------------------------------------------------------ Vars NumericSeries CumAmount; NumericSeries CumVol; NumericSeries nDay; Begin If (CurrentBar == 0) { CumAmount = Vol * Close; CumVol = Vol ; nDay = Date; }Else { If (nDay[1] != Date) { CumAmount = Vol * Close; CumVol = Vol ; }Else { CumAmount = CumAmount[1] + Vol * Close; CumVol = CumVol[1] + Vol; } nDay = Date; } PlotNumeric("AveragePrice",CumAmount/CumVol); End //------------------------------------------------------------------------ // 编译版本 GS2004.06.12 // 用户版本 2007-05-21 17:15 // 版权所有 TradeBlazer // 更改声明 TradeBlazer Software保留对TradeBlazer平台 // 每一版本的TrabeBlazer公式修改和重写的权利 //------------------------------------------------------------------------ PS:该公式计算的成交均价是按照每个Bar收盘价,存在着一定误差,在1Min及以下周期运行问题不大,在1Min之上可能引起较大的偏差。
看帮助我也觉得实在太累了,所以做了几个操作FLASH方便大家学习软件。大家可以去这个地址下载: PART1:http://www.wealth-lab.cn/download.php?file=a3404d0d7df5c2072763a12d9d775b0d PART2:http://www.wealth-lab.cn/download.php?file=28776af4091f19372ddbabab67dfa7f7