首页 > > 详细

帮做TB程序化公式、TB交易策略调试、开拓者夹板交易策略源码(振荡交易模型)

内容: 夹板在实盘中是一个很常见的运用,用于吃住震荡行情。它有个上轨和一个下轨,行情突破上轨就做空;突破下轨就做多,在上下轨之间来回吃。
OpenCoverFor2Lines函数代码

源码:
// 返回值: 1:有所动作,0:没有动作
// 返回值为非零时,把当前要建立的头寸大小和方向写入needPosition,把以什么价格去建立该头寸写入needPrice
// 返回值: 1:有所动作,0:没有动作
// 返回值为非零时,把当前要建立的头寸大小和方向写入needPosition,把以什么价格去建立该头寸写入needPrice

Params
Numeric currentPosition(0);
// 当前头寸,可正可负
NumericfirstLots(0);

Numeric wantShort(120);
// 开空仓位置
Numeric wantLong(8);
// 开多仓位置

NumericwantStopShort(0);
// 空头止损的位置
NumericwantStopLong(0);
// 多头止损的位置


// 注意:以下两个都是引用变量!!!!
NumericRefneedPosition;
// 经过计算后的当前头寸,正数:建立多仓,负数:建立空仓,零:平光所有头寸
NumericRef needPrice;
// 建立needPosition时的价格

Vars
Numeric tem;

Begin

// 14:55:00平掉当日所有头寸
if(time >= 0.1455 currentPosition != 0)
{
needPosition = 0;
needPrice = close ;
return 1;
}
if(currentPosition == 0)
{
// 无仓,准备侍机开仓
if(close = wantShort)
{
// 空头
needPosition = -1 * firstLots;
needPrice = wantShort;
return 1;

}
return 0;
}

if(currentPosition > 0)
{
// 持多仓,准备止损或反转
if(close >= wantShort)
{
// 反转
needPosition = -1 * firstLots;
needPrice = wantShort;
return 1;
}

if(close = wantStopShort)
{
// 止损
needPosition = 0;
needPrice = wantStopShort;
return 1;

}
return 0;
}
return 0;
End

联系我们 - QQ: 88652583
© 2014 www.93stock.com
代写选股公式网!
声明:警惕假冒分子冒充本站提供证券咨询服务,选股公式网为非证券咨询机构,本站不提供有关股评、投资分析报告、股市预测,证券咨询等服务。本站仅提供股票、期货、黄金、外汇的软件技术交流与分享。本站文章为互联网文章,其仅供参考,并不构成投资建议。