突破昨天最高价最低价今天开盘价运算出的上下轨日内交易策略
源码:
Params
Numeric PercentOfRange(0.8);
//突破参数N
Numeric ExitOnCloseMins(14.55);
//平仓时间
Numeric MinRange(0.2);
//最小Range
Numeric LastTradeMins(14.00);
//最后交易时间
Numeric BeginTradeMins(9.00);
Numeric Lots(1);
Numeric Stoplossset(1);
Vars
NumericSeries DayOpen;
NumericSeries preDayRange;
NumericSeries HigherAfterEntry;
NumericSeries LowerAfterEntry;
Numeric preDayHigh;
Numeric preDayLow;
Numeric UpperBand;
Numeric LowerBand;
Numeric MyPrice;
Numeric StopLine;
Begin
DayOpen=OpenD(0);
preDayHigh=HighD(1);
preDayLow=LowD(1);
preDayRange=HighD(1)-LowD(1);
UpperBand=DayOpen+preDayRange*PercentOfRange;
LowerBand=Dayopen-preDayRange*PercentOfRange;
If(BarsSinceEntry==1)
{
HigherAfterEntry=AvgEntryPrice;
LowerAfterEntry=HigherAfterEntry;
}Else If(BarsSinceEntry>1)
{
HigherAfterEntry=max (HigherAfterEntry[1],High[1]);
LowerAfterEntry=min(LowerAfterEntry[1],Low[1]);
}//
If(Date!=Date[1])
{DayOpen=Open;
preDayRange=preDayHigh-preDayLow;
If(preDayRange=UpperBandTimeMyprice)Myprice=Open;
Buy(1,Myprice);
Return;
}
If(MarketPosition!=1Low=ExitOnCloseMins/100)
{
Sell(1,Open);
BuyToCover(1,Open);
}
SetExitOncLOSE;
End