EasyTrader ArtNo 046
{ R-Break System }{ 當沖程式碼 5 min K}input:TimeEntry(905),TimeExit(1205),TimeFlat(1320),TradeProfit(0.04),TradeStopLoss(0.015),HLrange(50);
input:f1(0.4),f2(0.1),f3(0.1),xdiv(1.75),VL(1000),VS(1000);
var:SellCheck(0),BuyCheck(0),RevSell(0),RevBuy(0),TrendBuy(0),TrendSell(0),
DayLow(0),DayHigh(9999),startnow(0),div(0),Rangefilter(false),MP(0),VEnergy(0);
MP = MarketPosition ;
if currentbar=1 then startnow=0;
div=maxlist(xdiv,1);
{ Setup data while daily Market Open }
if date>date[1] then begin
startnow=startnow+1;
{ Calculate Ref Price box }
SellCheck=HighD(1)+f1*(CloseD(1)-LowD(1));
RevSell=((1+f2)/2)*(HighD(1)+CloseD(1))-(f2)*LowD(1);
RevBuy=((1+f2)/2)*(LowD(1)+CloseD(1))-(f2)*HighD(1);
BuyCheck=LowD(1)-f1*(HighD(1)-CloseD(1));
TrendBuy=SellCheck+f3*(SellCheck-BuyCheck);
TrendSell=BuyCheck-f3*(SellCheck-BuyCheck);
DayHigh = High;
DayLow = Low;
Rangefilter=HighD(1)-LowD(1)>=HLrange;
end;
if High > DayHigh then DayHigh = High;
if Low < DayLow then DayLow = Low;
if time >= TimeEntry and time < TimeExit and startnow>=2 and Rangefilter and date> entrydate(1) then begin
if DayHigh >= SellCheck and MP > -1 then
Sell ("Rev SE") next bar at RevSell+(DayHigh-SellCheck)/div stop;
if DayLow <= BuyCheck and MP < 1 then
Buy ("Rev LE") next bar at RevBuy-(BuyCheck-DayLow)/div stop;
if MP < 0 then Buy ("RbUP LE") next bar at entryprice*(1+TradeStopLoss) stop;
if MP > 0 then Sell ("RbDN SE")next bar at entryprice*(1-TradeStopLoss) stop;
if MP = 0 then Begin
Buy ("Break LE") next bar at TrendBuy stop;
Sell ("Break SE") next bar at TrendSell stop;
end;
end;
if time >= Timeflat then begin
if MP < 0 then ExitShort("RbUP SX") next bar at entryprice*(1+TradeStopLoss) stop ;
if MP > 0 then ExitLong ("RbDN LX") next bar at entryprice*(1-TradeStopLoss) stop ;
ExitShort ("Late SX") next bar at High+1 stop;
ExitLong ("Late LX") next bar at Low-1 stop;
end;
SetExitonClose ;
藍字部份去除改為留倉方式,台指期 5分K ,2013/11/1 往前 3000日 , 來回成本 1200
勝率不到30% 仍是獲利~~意思是賺大賠小 ,透過資金部位管控及加碼方式,還是有機會成為不錯的留倉策略的! ,有待看倌自己動手囉!!
SellCheck=HighD(1)+f1*(CloseD(1)-LowD(1));
RevSell=((1+f2)/2)*(HighD(1)+CloseD(1))-(f2)*LowD(1);
RevBuy=((1+f2)/2)*(LowD(1)+CloseD(1))-(f2)*HighD(1);
BuyCheck=LowD(1)-f1*(HighD(1)-CloseD(1));
TrendBuy=SellCheck+f3*(SellCheck-BuyCheck);
TrendSell=BuyCheck-f3*(SellCheck-BuyCheck);
DayHigh = High;
DayLow = Low;
Rangefilter=HighD(1)-LowD(1)>=HLrange;
end;
if High > DayHigh then DayHigh = High;
if Low < DayLow then DayLow = Low;
if time >= TimeEntry and time < TimeExit and startnow>=2 and Rangefilter and date> entrydate(1) then begin
if DayHigh >= SellCheck and MP > -1 then
Sell ("Rev SE") next bar at RevSell+(DayHigh-SellCheck)/div stop;
if DayLow <= BuyCheck and MP < 1 then
Buy ("Rev LE") next bar at RevBuy-(BuyCheck-DayLow)/div stop;
if MP < 0 then Buy ("RbUP LE") next bar at entryprice*(1+TradeStopLoss) stop;
if MP > 0 then Sell ("RbDN SE")next bar at entryprice*(1-TradeStopLoss) stop;
if MP = 0 then Begin
Buy ("Break LE") next bar at TrendBuy stop;
Sell ("Break SE") next bar at TrendSell stop;
end;
end;
if time >= Timeflat then begin
if MP < 0 then ExitShort("RbUP SX") next bar at entryprice*(1+TradeStopLoss) stop ;
if MP > 0 then ExitLong ("RbDN LX") next bar at entryprice*(1-TradeStopLoss) stop ;
ExitShort ("Late SX") next bar at High+1 stop;
ExitLong ("Late LX") next bar at Low-1 stop;
end;
SetExitonClose ;
藍字部份去除改為留倉方式,台指期 5分K ,2013/11/1 往前 3000日 , 來回成本 1200
勝率不到30% 仍是獲利~~意思是賺大賠小 ,透過資金部位管控及加碼方式,還是有機會成為不錯的留倉策略的! ,有待看倌自己動手囉!!
MagicQS007
沒有留言:
張貼留言