温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,汇文网负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
网站客服:3074922707
rrquantC47
//------------------------------------------------------------------------
// 简称 rrquantC47
// 名称 人人宽客C47
// 类别 公式应用
// 类型 用户应用
// 输出 Void
//------------------------------------------------------------------------
//策略思路:全品种中长线加仓通用策略:拳头;进场:双均线+收盘价过滤,同时也是反向进场点。盈利一定幅度,加仓一次。出场:ATR止损+棘轮止盈。
//适用软件:TB
//公式名称:人人宽客C47
//数据周期:日
//数据合约:指数合约
//交易合约:主力合约
//适合品种:苹果/玉米/淀粉/铁矿/焦炭/郑醇/PP/螺纹/橡胶/锰硅/郑煤等
Params
//此处添加参数
Numeric Length1( 5 );
Numeric Length2( 20 );
Numeric M_HL( 10 );
Numeric Fund( 20000 );
Vars
//此处添加变量
NumericSeries Var1( 0 );
NumericSeries TR( 0 );
NumericSeries ATR( 0 );
NumericSeries MA1( 0 );
NumericSeries MA2( 0 );
NumericSeries N_BuyK( 0 );
NumericSeries N_SellK( 0 );
NumericSeries ATR_BuyK( 0 );
NumericSeries ATR_SellK( 0 );
NumericSeries Price_BuyK( 0 );
NumericSeries Price_SellK( 0 );
NumericSeries Price_BuyAK( 0 );
NumericSeries Price_SellAK( 0 );
NumericSeries Price_SellS( 0 );
NumericSeries Price_BuyS( 0 );
NumericSeries Price_SellY( 0 );
NumericSeries Price_BuyY( 0 );
BoolSeries BuyPK( false );
BoolSeries SellPK( false );
BoolSeries BuyAK( false );
BoolSeries SellAK( false );
BoolSeries BuyA( false );
BoolSeries SellA( false );
BoolSeries BuyS( false );
BoolSeries SellS( false );
BoolSeries BuyY( false );
BoolSeries SellY( false );
Begin
//此处添加代码正文
Var1=Max(1,IntPart(Fund/(Open*ContractUnit*BigPointValue*0.1)));
TR=Max(Max((High-Low),Abs(Close[1]-High)),ABS(Close[1]-Low));
ATR=Average(TR,Length2);
MA1=Average(Close,Length1);
MA2=Average(Close,Length2);
N_BuyK=BarsSinceEntry+1;
N_SellK=BarsSinceEntry+1;
BuyPK=High>=Highest(High,Length1) && MA1>MA2;
SellPK=Low<=Lowest(Low,Length1) && MA1<MA2;
BuyAK=Close>Price_BuyAK;
SellAK=Close<Price_SellAK;
SellS=Close<=Price_SellS;
BuyS=Close>=Price_BuyS;
SellY=Close>Price_BuyK+ATR_BuyK && Close<=Price_SellY;
BuyY=Close<Price_SellK-ATR_SellK && Close>=Price_BuyY;
Price_SellY=Lowest(Low,M_HL)+N_BuyK*0.05*ATR;
Price_BuyY=Highest(High,M_HL)-N_SellK*0.05*ATR;
if (CurrentBar>Length2)
{
If (MarketPosition<=0 and BuyPK[1])
{
Buy(Var1,O);
Commentary("BPK");
ATR_BuyK=ATR;
Price_BuyK=Open;
Price_BuyAK=Price_BuyK+ATR;
Price_SellS=Price_BuyK-2*ATR;
BuyA=false;
}
If (MarketPosition>=0 and SellPK[1])
{
SellShort(Var1,O);
Commentary("SPK");
ATR_SellK=ATR;
Price_SellK=Open;
Price_SellAK=Price_SellK-ATR;
Price_BuyS=Price_SellK+2*ATR;
SellA=false;
}
if (BarsSinceEntry>1)
{
If (MarketPosition>0)
{
if (BuyA==false and BuyAK[1])
{
Buy(Var1,O);
Commentary("BAK");
BuyA=True;
}
if (SellS[1])
{
Sell(0,O);
Commentary("SS");
}
if (SellY[1])
{
Sell(0,O);
Commentary("SY");
}
}
If (MarketPosition<0)
{
if (SellA==false and SellAK[1])
{
SellShort(Var1,O);
Commentary("SAK");
SellA=True;
}
If (BuyS[1])
{
BuyToCover(0,O);
Commentary("BS");
}
If (BuyY[1])
{
BuyToCover(0,O);
Commentary("BY");
}
}
}
}
/*
PlotNumeric("Price_SellS",Price_SellS);
Commentary("N_BuyK"+Text(N_BuyK));
Commentary("SellAK="+IIFString(SellAK,"True","False"));
*/
End
//------------------------------------------------------------------------
// 编译版本 2018-05-01 151201
// 内核版本 V2.8.2.14
// 版权所有 rrquant
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------