开拓者期货期权程序化系统交易论坛
标题:
rb原型收藏
[打印本页]
作者:
htqh81102667
时间:
2016-7-26 14:57:08
标题:
rb原型收藏
dual thrust系统原形
Inputs: K1(.5),K2(.5),Mday(1),Nday(1);
Vars: BuyRange(0), SellRange(0);
Vars: BuyTrig(0),SellTrig(0);
Vars: HH(0),LL(0),HC(0),LC(0);
If CurrentBar > 1 Then Begin
HH = Highest(High,Mday);
HC = Highest(Close,Mday);
LL = Lowest(Low,Mday);
LC = Lowest(Close,Mday);
If (HH - LC) >= (HC - LL) Then Begin
SellRange = HH - LC;
End Else Begin
SellRange = HC - LL;
End;
HH = Highest(High,Nday);
HC = Highest(Close,Nday);
LL = Lowest(Low,Nday);
LC = Lowest(Close,Nday);
If (HH - LC) >= (HC - LL) Then Begin
BuyRange = HH - LC;
End Else Begin
BuyRange = HC - LL;
End;
BuyTrig = K1*BuyRange;
SellTrig = K2*SellRange;
If MarketPosition = 0 Then Begin
Buy at Open of next bar + BuyTrig Stop;
Sell at Open of next bar - SellTrig Stop;
End;
If MarketPosition = -1 Then Begin
Buy at Open of next bar + Buytrig Stop;
End;
If MarketPosition = 1 Then Begin
Sell at Open of next bar - SellTrig Stop;
End;
End;
作者:
htqh81102667
时间:
2016-7-26 14:57:39
//------------------------------------------------------------------------
// 简称: dual_thrust
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出: 穿堂风
//------------------------------------------------------------------------
Params
Numeric K1(0.5);
Numeric K2(0.5);
Numeric Mday(1);
Numeric Nday(1);
Numeric lots(1);
Numeric offset(0);
Vars
Numeric BuyRange(0);
Numeric SellRange(0);
Numeric BuyTrig(0);
Numeric SellTrig(0);
Numeric HH;
Numeric LL;
Numeric HC;
Numeric LC;
Numeric i_offset;
Numeric BuyPosition;
Numeric SellPosition;
Begin
If(CurrentBar > 44*Max(Mday,Nday))//使用的是5分钟周期,其它的周期自己做相应修改
{
i_offset = offset*MinMove*PriceScale;
HH = Highest(HighD(1),Mday);
HC = Highest(CloseD(1),Mday);
LL = Lowest(LowD(1),Mday);
LC = Lowest(CloseD(1),Mday);
If((HH - LC) >= (HC - LL))
{
SellRange = HH - LC;
}
Else
{
SellRange = HC - LL;
}
HH = Highest(HighD(1),Nday);
HC = Highest(CloseD(1),Nday);
LL = Lowest(LowD(1),Nday);
LC = Lowest(CloseD(1),Nday);
If((HH - LC) >= (HC - LL))
{
BuyRange = HH - LC;
}
Else
{
BuyRange = HC - LL;
}
BuyTrig = K1*BuyRange;
SellTrig = K2*SellRange;
BuyPosition = OpenD(0)+BuyTrig;
SellPosition = OpenD(0)-SellTrig;
PlotNumeric("BuyPosition",BuyPosition);
PlotNumeric("SellPosition",SellPosition);
If(MarketPosition == 0)
{
If(High>=BuyPosition)
{
Buy(lots,Max(Open,BuyPosition)+i_offset);
Return;
}
If(Low<=SellPosition)
{
SellShort(lots,Min(Open,SellPosition)-i_offset);
Return;
}
}
If(MarketPosition == -1)
{
If(High>=BuyPosition)
{
Buy(lots,Max(Open,BuyPosition)+i_offset);
Return;
}
}
If(MarketPosition == 1)
{
If(Low<=SellPosition)
{
SellShort(lots,Min(Open,SellPosition)-i_offset);
Return;
}
}
}
End
//------------------------------------------------------------------------
// 编译版本 GS2010.12.08
// 用户版本 2011/07/24 02:14
// 版权所有 穿堂风
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------
欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/)
Powered by Discuz! X2