看视频学习的不对 [开拓者 TB]
-
咨询内容:
//------------------------------------------------------------------------
// 简称:
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出: Void
Params
Numeric Length(20);
Numeric Offset(2);
Numeric lots(0);
Numeric stoploss[50];
Numeric takeprofit[50];
Vars
NumericSeries UpLine; //上轨
NumericSeries DownLine; //下轨
NumericSeries MidLine; //中间线
Numeric Band;
Numeric STOPLOSSPRICE;
Numeric takeprofitprice;
Begin
MidLine = AverageFC(Close,Length);
Band = StandardDev(Close,Length,2);
UpLine = MidLine + Offset * Band;
DownLine = MidLine - Offset * Band;
PlotNumeric("UpLine",UpLine);
PlotNumeric("DownLine",DownLine);
PlotNumeric("MidLine",MidLine);
IF(MarketPosition<>1 and high>=upline[1])
{
buy (lots,max(open,upline[1]));
}
//多头止损
stoplossprice = EntryPrice -stoploss;
If(MarketPosition==1 and barssinceentry >0 AND L<=STOPLOSSPRICE)
{
SELL(0,MIN(OPEN,STOPLOSSPRICE));
}
//多头止赢
TAKEPROFITPRICE = EntryPrice +TAKEPROFIT;
If(MarketPosition==1 and barssinceentry >0 AND h>=TAKEPROFITPRICE)
{
SELL(0,Max(OPEN,TAKEPROFITPRICE));
}
IF(MarketPosition<>-1 and low<=DownLine[1])
{
SellShort (lots,min(open,DownLine[1]));
}
//空头止损
TAKEPROFITPRICE = EntryPrice +TAKEPROFIT;
If(MarketPosition==1 and BarsSinceExit >0 AND h>=TAKEPROFITPRICE)
{
BuyToCover(0,Max(OPEN,TAKEPROFITPRICE));
}
//空头止赢
stoplossprice = EntryPrice -stoploss;
If(MarketPosition==1 and BarsSinceExit >0 AND L<=STOPLOSSPRICE)
{
BuyToCover(0,MIN(OPEN,STOPLOSSPRICE));
}
End
//------------------------------------------------------------------------
// 编译版本: 2018/05/25 204227
// 内核版本: V2.8.2.14
// 版权所有
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------
想跟据macd 50个点止损止赢来源:CXH99.COM
-
TB技术人员:
运行出来不对呀
-
TB客服:
改了一下 单独测试多头的止损止赢可以
空头的不知道哪里还没对 求大神帮忙
Params
Numeric Length(20);
Numeric Offset(2);
Numeric lots(0);
Numeric stoploss[50];
Numeric takeprofit[50];
Vars
NumericSeries UpLine; //上轨
NumericSeries DownLine; //下轨
NumericSeries MidLine; //中间线
Numeric Band;
Numeric STOPLOSSPRICE;
Numeric takeprofitprice;
Numeric kLOSSPRICE;
Numeric kprofitprice;
Begin
MidLine = AverageFC(Close,Length);
Band = StandardDev(Close,Length,2);
UpLine = MidLine + Offset * Band;
DownLine = MidLine - Offset * Band;
PlotNumeric("UpLine",UpLine);
PlotNumeric("DownLine",DownLine);
PlotNumeric("MidLine",MidLine);
IF(MarketPosition<>1 and high>=upline[1])
{
buy (lots,max(open,upline[1]));
}
//多头止损
stoplossprice = EntryPrice -50;
If(MarketPosition==1 and barssinceentry >0 AND L<=STOPLOSSPRICE)
{
SELL(0,MIN(OPEN,STOPLOSSPRICE));
}
//多头止赢
TAKEPROFITPRICE = EntryPrice +50;
If(MarketPosition==1 and barssinceentry >0 AND h>=TAKEPROFITPRICE)
{
SELL(0,Max(OPEN,TAKEPROFITPRICE));
}
IF(MarketPosition<>-1 and low<=DownLine[1])
{
SellShort (lots,min(open,DownLine[1]));
}
//空头止损
kPROFITPRICE = ExitPrice +40;
If(MarketPosition== -1 and BarsSinceExit <0 AND h>=kPROFITPRICE)
{
BuyToCover(0,Min(OPEN,kPROFITPRICE));
}
//空头止赢
klossprice = ExitPrice -40;
If(MarketPosition==-1 and BarsSinceExit <0 AND L<=kLOSSPRICE)
{
BuyToCover(0,Max(OPEN,kLOSSPRICE));
}
End -
网友回复:
老师帮我改一下空头出场的 应该是哪里错了
- 网友回复:
vvvtzi 发表于 2018-5-25 23:15
改了一下 单独测试多头的止损止赢可以
空头的不知道哪里还没对 求大神帮忙
barssinceexit<0在这里是表示了什么意思?
这个函数是不存在小0的值的,只有当MarketPosition = 0时,即没有持仓的状况下,该函数才有意义,否则返回0。
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容