EasyTrader ArtNo 24
自部落格開張到今日,瀏覽人次剛破千,感謝讀者的支持,請樓上招樓下,厝頭招厝尾,有空逛逛喔!
10/16 結算日: 開放 TS2000i 程式碼學習,純研究,勿用作實單交易
inputs: TradeProfit(0.05),TradeStopLoss(0.03);
Inputs: MultBuy(2.2),MultSell(3.4),MinPL(90),TradeMovPL(180),BuyLength(12),SellLength(12);
vars: KeepPL(True),MP(0),IsBalanceDay(False);
MP = MarketPosition ;
if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then isBalanceDay = True else isBalanceDay =False ;
{ ----- Preparation of Trade Setup -----}
if IsBalanceDay = False then
Buy ("VLB") Next Bar at Open Next Bar + Average(Range, BuyLength) * MultBuy Stop;
if IsBalanceDay = False then
if IsBalanceDay = False then
Sell ("VLS") Next Bar at Open Next Bar - Average(Range, SellLength) * MultSell Stop;
{ ----- Exit of Long Trade -----}
if MP > 0 then Begin
if MP > 0 and High > EntryPrice*(1 + TradeProfit) then
{ ----- Exit of Long Trade -----}
if MP > 0 then Begin
if MP > 0 and High > EntryPrice*(1 + TradeProfit) then
ExitLong at EntryPrice*(1 + TradeProfit) stop;
if MP > 0 and Low < EntryPrice*(1 - TradeStopLoss) then
if MP > 0 and Low < EntryPrice*(1 - TradeStopLoss) then
ExitLong at EntryPrice*(1 - TradeStopLoss) stop;
if IsBalanceDay = False and MP > 0 and KeepPL and Highest(High, BarsSinceEntry)-EntryPrice > MinPL then Sell at Highest(High, BarsSinceEntry)-TradeMovPL Stop;
end;
{ ----- Exit of Short Trade -----}
if MP < 0 then Begin
if MP < 0 and Low < EntryPrice*(1 - TradeProfit) then
if IsBalanceDay = False and MP > 0 and KeepPL and Highest(High, BarsSinceEntry)-EntryPrice > MinPL then Sell at Highest(High, BarsSinceEntry)-TradeMovPL Stop;
end;
{ ----- Exit of Short Trade -----}
if MP < 0 then Begin
if MP < 0 and Low < EntryPrice*(1 - TradeProfit) then
ExitShort at EntryPrice*(1 - TradeProfit) stop;
if MP < 0 and High > EntryPrice*(1+ TradeStopLoss) then
if MP < 0 and High > EntryPrice*(1+ TradeStopLoss) then
ExitShort at EntryPrice(1 + TradeStopLoss) stop;
if IsBalanceDay = False and MP < 0 and KeepPL and EntryPrice-(Lowest(Low, BarsSinceEntry)) > MinPL then Buy at Lowest(Low, BarsSinceEntry) + TradeMovPL Stop;
end;
{ ----- Balance on Monthly BalanceDay -----}
if IsBalanceDay then begin
if time >= 1315 then begin
if MP > 0 then ExitLong next bar at market ;
if MP < 0 then ExitShort next bar at market ;
end ;
if IsBalanceDay = False and MP < 0 and KeepPL and EntryPrice-(Lowest(Low, BarsSinceEntry)) > MinPL then Buy at Lowest(Low, BarsSinceEntry) + TradeMovPL Stop;
end;
{ ----- Balance on Monthly BalanceDay -----}
if IsBalanceDay then begin
if time >= 1315 then begin
if MP > 0 then ExitLong next bar at market ;
if MP < 0 then ExitShort next bar at market ;
end ;
end;
E大
回覆刪除感恩
TKS
E大你好,小弟是初學者請問在這段程式碼中 Buy ("VLB") Next Bar at Open Next Bar + Average(Range, BuyLength) * MultBuy Stop;這一段是不是跟這一段 Buy ("VLB") Next Bar at Open + Average(Range, BuyLength) * MultBuy Stop;是一樣的嗎?還是有所不同?可請E大教導?謝謝!
回覆刪除前面是以下根K棒開盤為基準 ,後面是以此根K棒開盤為基準
回覆刪除