EasyTrader 比特幣測試 06
這是一個運用 RSI 鈍化 與 一目均衡表 作為進出邏輯的交易策略
// Public Variable
vars:MP(0),PF(0),PL(0),LotNum(1),BuyPrice(0),ShortPrice(0),BasePF(150),BasePL(100),FilterA(0),FilterB(0) ;
vars:BarPass(5),HLRange(0),WinPoint(0),HBarPos(0),LBarPos(0),ExitH(0),ExitL(0),TimeOK(false),EntryExitCond(false),SelectNo(0) ;
//****************** Basic Setup ****************************************
MP = MarketPosition ;
if MP <> 0 then Begin
PF = EntryPrice*TradeProfit ;
PL = EntryPrice*TradeStopLoss ;
end else begin
PF = AvgPrice*TradeProfit ;
PL = AvgPrice*TradeStopLoss ;
end ;
PF = MinList(PF,3000) ;
PL = MinList(PL,1500) ;
// ************* BreskThrough 3 Line *************
vars:Avg7(0),Avg13(0),Avg21(0),Avg60(0) ;
vars:Max3L(0),Min3L(0);
Avg7 = Average(Close,7) ;
Avg13 = Average(Close,13) ;
Avg21 = Average(Close,21) ;
Avg60 = Average(Close,60) ;
Max3L = MaxList(Avg7,Avg13,Avg21) ;
Min3L = MinList(Avg7,Avg13,Avg21) ;
// ************ RSI *****************
vars:vRSIA(0),vRSIB(0),DivRSICondA(false),DivRSICondB(false) ;
vRSIA = RSI(Close,LenA1) ;
vRSIB = RSI(Close,LenB1) ;
// ************ Ichimoku Sanjin Syytem *****************
Vars: ShortTerm(9),MidTerm(26),LongTerm(52);
Vars: ConvertLine(0),BaseLine(0),AheadLine1(0),AheadLine2(0),BehindLine(0),HighCloud(0),LowCloud(0),Cloud(0) ;
Vars: BaseCond(false),ConvertCond(false),C_over_B(0),C_Under_B(0),H_Over_L(0),H_Under_L(0),Thick(100) ;
vars: CondL(false),CondS(false) ;
ShortTerm = LenA1 ;
if ShortTerm <= 8 then ShortTerm = 8
else if ShortTerm >= 20 then ShortTerm = 20 ;
MidTerm = ShortTerm*3 ;
LongTerm = ShortTerm*6 ;
ConvertLine = (highest(high,ShortTerm) + Lowest(Low,ShortTerm))/2 ;
BaseLine = (highest(high,MidTerm) + Lowest(Low,MidTerm))/2 ;
AheadLine1 = (ConvertLine + BaseLine)/2 ;
AheadLine2 = (highest(high,LongTerm) + Lowest(Low,LongTerm))/2 ;
BehindLine = Close ;
C_over_B = _BarsLast(ConvertLine cross over BaseLine) ;
C_Under_B = _BarsLast(ConvertLine cross under BaseLine) ;
HighCloud = AheadLine1[MidTerm] ;
LowCloud = AheadLine2[MidTerm] ;
Cloud = AbsValue(HighCloud-LowCloud) ;
H_Over_L = _BarsLast(HighCloud cross over LowCloud) ;
H_under_L = _BarsLast(HighCloud cross under LowCloud) ;
CondL = Close > HighCloud and HighCloud > LowCloud ;
CondS = Close < HighCloud and HighCloud < LowCloud ;
//**************************************************
if BarNumber = 1 then begin
Buy this bar on Close ;
Sell this bar on Close ;
end ;
// ************* Time Set Up *************
TimeOK = ((time >= 1000 and time <= 1400) or (time >= 2000 and time <= 2358)) ;
// ************* Entry/Exit Condition Set Up *************
vars:MoneyLoss(false),LossCount(false),MoneyProfit(false),ProfitCount(false),ProfitCond(false),LossCond(false),ExitLen(0) ;
if Totaltrades > 6 then begin
MoneyLoss = positionprofit(1)+positionprofit(2) < -1*(Close*0.01)*200 ;
LossCount = positionprofit(1) < 0 and positionprofit(2) < 0 and positionprofit(3) < 0 ;
LossCond = MoneyLoss or LossCount ;
MoneyProfit = positionprofit(1)+positionprofit(2) > (Close*0.02)*200 ;
ProfitCount = positionprofit(1) > 0 and positionprofit(2) > 0 and positionprofit(3) > 0 ;
ProfitCond = MoneyProfit or ProfitCount ;
end else begin
LossCond = true ;
ProfitCond = true ;
end ;
ExitLen = iff(ProfitCond,1080/BarInterval,iff(LossCond,2160/BarInterval,MaxList(LenA1,LenB1))) ;
EntryExitCond = BarsSinceExit(1) > ExitLen ;
//***************** BuyPrice & ShortPrice Setup *****************
BuyPrice = Highest(High,Hbar) ;
ShortPrice = (Highest(High,Lbar)+Lowest(Low,Lbar))*0.5 ;
// ********** Main Strategy *********
// ********** Entry Method
if EntryExitCond then begin
if MP <> 1 and Low Cross over HighCloud and HighCloud > LowCloud and HighCloud > Avg60 then
buy ("LE_MoKu7") LotNum Contracts next bar at Market ;
if MP <> -1 and High Cross under HighCloud and HighCloud < LowCloud and HighCloud < Avg60 then
sellshort ("SE_MoKu7") LotNum Contracts next bar at Market ;
end ;
if EntryExitCond then begin
if MP <> 1 and Countif(vRSIA > MaxList(HighBand*4,65),8) >= 4 and Close < BuyPrice then
Buy ("LE_RSI3") LotNum Contracts next bar at BuyPrice stop ;
if MP <> -1 and Countif(vRSIB < MinList(LowBand*4,35),8) >= 4 and Close > ShortPrice then
SellShort ("SE_RSI3") LotNum Contracts next bar at ShortPrice stop ;
end ;
// ************* Base Exit *************
if MP > 0 then Sell ("Trail_PL1_"+NumtoStr(Absvalue(EntryPrice-(HighSinceEntry-MinList(PL,PF))),2))
All Contracts next bar at HighSinceEntry-MinList(PL,PF) stop ;
if MP > 0 then Sell ("PF1_"+NumtoStr(PF,0)) All Contracts next bar at EntryPrice+PF limit ;
if MP < 0 then BuytoCover ("Trail_PL2_"+NumtoStr(Absvalue(EntryPrice-(LowSinceEntry+MinList(PL,PF))),2))
All Contracts next bar at LowSinceEntry+MinList(PL,PF) stop ;
if MP < 0 then BuytoCover ("PF2_"+NumtoStr(PF,0)) All Contracts next bar at EntryPrice-PF limit ;
end ;
比特幣 留倉 交易週期 2017/6/1 ~ 2024 交易成本 交易量*0.1%
沒有留言:
張貼留言