input: Length(10), BES(10), LengthADX(10), SD(.8), Length1(10), Length2(35);
if close > highest(high, length)[1]+StdDev(close,20)[1]*SD and SlowD(14)<20 then buy ("b1") on close;
if close < highest(high, length)[1]-StdDev(close,20)[1]*SD and SlowD(14)>80 then sell("s1") on close;
exitlong ("stop1") from entry ("b1") at$ Close-2*StdDev(close,10) stop;
exitshort ("stop2") from entry ("s1") at$ close+2*StdDev(close,10) stop;
if ADX(LengthADX) > 40 then begin
if average(close, Length1) crosses below average(close, Length2) then exitlong ("exitL1");
if average(close, Length1) crosses above average(close, Length2) then exitshort ("exitS1");
end
else begin
if ADX(LengthADX) < 20 then begin
if BarsSinceEntry=BES then
exitlong ("exitL2");
if BarsSinceEntry=BES then
exitshort ("exitS2");
end
else begin
if SlowD(50) > 85 then
exitlong("exitL3");
if SlowD(50) < 15 then
exitshort("exitS3");
end;
end;
程式碼還滿短的…跑出來的績效雖然是正的…不過也不太能看,所以才說要經過大修改…
有興趣的就自己參考吧。
疑 DK大大 請問為什麼我把程式碼放入TS之後,出來的只有SELL 沒有BUY呢 謝謝
回覆刪除love760723: 還是有啦…只是多單很少出現而已。
回覆刪除試著把多單變這樣就會出現很多啦:
if close > lowest(low, length)[1]+StdDev(close,20)[1]*SD and SlowD(14)<20 then buy ("b1") on close;