首页 > > 详细

调试TB交易策略、股票选股公式代写、开拓者一个简单顺势交易系统策略源码-开拓者公式


该交易系统的建仓条件为:
1、前两个Bar收阳,并呈上涨趋势;
2、当前价格为最近前2个Bar最高价的回落,而且回落幅度大于0.382。回落幅度是相对于最高价到最低价的范围。//
该交易系统的平仓条件为:
1、当前价格的获利价格点数大于建仓时最低价到最低价的范围。
该交易系统的止损条件为:
1、当前价格从建仓时的最高价格的回落大于最低价到最高价的范围的0.5。
源码:
Params
Numeric TrailingSet(0.382);
// 回撤开仓比例设置,从最高点下跌的比例
Numeric StopLossSet(0.5);
// 止损比例设置
Vars
Bool startCondition(False);
// 启动条件
Bool EntryCondition(False);
// 开仓条件
Bool ExitCondition(False);
// 平仓条件
NumericSeries highestValue(0);
// 前2个周期的最高价
NumericSeries lowestValue(0);
// 前2个周期的最低价
Numeric myEntryPrice(0);
// 开仓价格
Numeric myExitPrice(0);
// 平仓价格
Begin
highestValue = highestValue[1];
lowestValue = lowestValue[1];
//
If(MarketPosition ==0 ) // 当前空仓
{
If(Close[2]>Open[2] Close[1] > Open[1] Close[1] > Close[2])
{
startCondition = True;
highestValue = max(high[2],high[1]);
lowestValue = min(low[2],low[1]);
}

If(startCondition)
{
EntryCondition = ((highestValue - Open) / (highestValue - lowestValue) > TrailingSet ) // 开盘价即满足回撤条件,用开盘价进行交易
(Open > highestValue -((highestValue - lowestValue)*StopLossSet)) ;
// 开盘价不能低于预设的止损价
If( EntryCondition)
{
Buy(1,Open);
}Else // 再看其它价格是否满足
{
EntryCondition = (highestValue - Low) / (highestValue - lowestValue) > TrailingSet ;
// 最低价满足回撤条件,用低于TrailingSet设置的最近价位建仓
If(EntryCondition)
{
myEntryPrice = highestValue - (HighestValue - LowestValue ) * TrailingSet;
myEntryPrice = IntPart(myEntryPrice / (PriceScale()*MinMove)) *(PriceScale()*MinMove);
// 对价格进行处理
If(myEntryPrice >= low myEntryPrice StopLossSet;
// 止损条件满足
If(ExitCondition)
{
myExitPrice = highestValue - (HighestValue - LowestValue ) * StopLossSet;

myExitPrice = IntPart(myExitPrice / (PriceScale()*MinMove)) *(PriceScale()*MinMove);
// 对价格进行处理
Sell(CurrentContracts(),myExitPrice);
}Else // 获利平仓
{
ExitCondition = (high - AvgEntryPrice()) > (highestValue - lowestValue);
// 获利平仓条件满足
If(ExitCondition)
{
myExitPrice = AvgEntryPrice() + (HighestValue - LowestValue );

myExitPrice = IntPart(myExitPrice / (PriceScale()*MinMove)) *(PriceScale()*MinMove);
// 对价格进行处理
If (myExitPrice >= low myEntryPrice <= high)
{
Sell(CurrentContracts(),myExitPrice);
}Else
{
Sell(CurrentContracts(),Close);
}
}
}
}
End




 

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