EasyTrader 比特幣測試 07
彈性指數動態平均線(VIDYA)
// 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) ;
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) ;
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,2700) ;
PL = MinList(PL,1350) ;
// ************ CDP *****************
vars:CDP(0),AH(0),NH(0),NL(0),AL(0),CDPrange(0),CrossA(false),CrossB(false),TH1(0),TL1(0),TH2(0),TL2(0) ;
if Date <> Date[1] then begin
CDP = (HighD(1)+LowD(1)+2*CloseD(1))/4;
AH = CDP + (HighD(1) - LowD(1));
NH = CDP*2 - LowD(1);
NL = 2*CDP - HighD(1);
AL = CDP - (HighD(1) - LowD(1));
end ;
// ************ for week High/Low box *****************
Vars:WeekLong(5),WeekShort(5),WH(0),WL(0),HLWeek(0),WCount(0),WBox33(0),WBox67(0) ;
WH = 近週高點 ;
WL = 近週低點;
// ************ Volatility ExPansion System *****************
vars: VED(1),DBody(1) ;
VED = HighD(1)-LowD(1) ;
if absvalue(CloseD(1)-OpenD(1)) <> 0 and VED <> 0 then DBody = absvalue(CloseD(1)-OpenD(1))/VED ;
//* Vidya Setup
vars:Vidya1(1),Vidya2(1) ;
Vidya1 = _SS_Vidya(LenA1,FracA) ;
Vidya2 = _SS_Vidya(LenB1,FracB) ;
//**************************************************
if BarNumber = 1 then begin
Buy this bar on Close ;
Sell this bar on Close ;
end ;
// ************* Entry/Exit Condition Set Up *************
SelectNo = IntPortion(RatioL*2+0.3) ;
if SelectNo < 1 or SelectNo > 11 then SelectNo = 1 ;
if SelectNo = 2 then EntryExitCond = EntriesToday(Date)=0 ;
//***************** BuyPrice & ShortPrice Setup *****************
BuyPrice = OpenD(0)+MaxList(VED*FracA/6,21) ;
ShortPrice = LowM(0)+(HighM(0)-LowM(0))*0.33 ;
// ********** Main Strategy *********
// ********** Entry Method
if EntryExitCond then begin
if MP <> -1 and Close < AH and Close > NH then
Buy ("LE_CDP5") LotNum Contracts next bar at WH stop ;
if MP <> -1 and Close > AL and Close < NL then
SellShort ("SE_CDP5") LotNum Contracts next bar at WL stop ;
end ;
if EntryExitCond then begin
if MP <> 1 and Countif(Vidya1 > Vidya1[1],3) = 3 and Close > NH and Close < BuyPrice then
Buy ("LE_Vidya2") LotNum Contracts next bar at BuyPrice stop;
if MP <> -1 and Countif(Vidya2 < Vidya2[1],3) = 3 and Close < NL and Close > ShortPrice then
SellShort ("SE_Vidya2") 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 ;
比特幣 留倉 交易週期 2017/6/1 ~ 2024 交易成本 交易量*0.1%
沒有留言:
張貼留言