不好意思 我想寫一個期貨時間通道突破的腳本,9:40後突破高點做多,跌破低點做空。
停損 1.5%, 停利375點
但跑回測出來去看 交易分析 發現很多應該要啟動訊號卻沒有執行
想請教腳本的語法有甚麼問題?
非常感謝
//我寫的腳本如下
input: timeline(094000); setinputName(1,"時間切算點");
input: TXT1("限用分鐘線"); setinputname(2,"使用限制");
input: TXT2("高點字開盤起算"); setinputname(3,"使用說明");
settotalBar(3);
if barfreq<> "Min" then return;
variable: rangehigh(0), rangelow(0), BCost(0), BOut(0), SCost(0), SOut(0);
if date <> date[1] then rangehigh = 0;
if date <> date[1] then rangelow = 0;
if time < timeline then rangehigh = maxlist(rangehigh, high);
if time < timeline then rangelow = minlist(rangelow, low);
// 進場區(多方)
if time >= timeline and rangehigh > 0 and close > rangehigh and position<=0 then
begin
setposition(1);
BCost=C;
BOut=C*0.985;
end;
// 出場區(多方)
if position=1 and C<BOut then setposition(0)
else if position=1 and C>BCost+375 then setposition(0);
// 進場區(空方)
if time >= timeline and rangelow > 0 and close < rangelow and position>=0 then
begin
setposition(-1);
SCost=C;
SOut=C*1.015;
end;
// 出場區(空方)
if position=-1 and C>SOut then setposition(0)
else if position=-1 and C<SCost-375 then setposition(0);
 
            
        
        
            
1 評論