
想請教該如何避免腳本在開始洗價之前,就已經將設定的變數給改變了的問題,以至於後續有符合條件要做進場時,不能如預期中的那樣做觸發進場的動作。
我撰寫的自動交易中心腳本如下,並在腳本設定的介面設定好SS1、SS2的值進行測試(附件有上傳CSV檔案)
Input:SS1(0,"自訂壓力價上緣"),SS2(0,"自訂壓力價下緣"),BB1(0,"自訂支撐價上緣"),BB2(0,"自訂支撐價下緣");
Variables:IntraBarPersist MKP(0),IntraBarPersist SUpper(0),IntraBarPersist SLower(0),IntraBarPersist BUpper(0),IntraBarPersist BLower(0);
Variables:Con_Tout(False),ConT(False),conB1(False),conS1(False),conB2(False),conS2(False);
Array:IntraBarPersist RTime[10](0);
//*****************************************************
if Time>=084500 and Time<=134500 then ConT=True else ConT=False;
value6 = GetSymbolField("FITX*1.TF","最高價","D");
value7 = GetSymbolField("FITX*1.TF","最低價","D");
value8 = GetSymbolField("FITX*1.TF","收盤價","D");
ConS2 = value8 > SS2 and value8 < SS1 and value6 < SS1;
conB2 = value8 < BB1 and value8 > BB2 and value7 > BB2;
Print("Line 19_MKP=",MKP);
//======================================條件觸發進出場區======================================
if conS2[0]=True and Filled=0 and Position=0 and MKP=0 and Con_Tout=False then begin
MKP = -1;
Print("Line 23");
SetPosition(-1,Market,Label:="1st_空單"); { 1st_空 }
Print("Line 25");
end;
//===================DeBug區===================
if GetInfo("IsRealTime")=1 and CurrentTime>=TimeAdd(RTime[7],"S",5) then begin
Print("SS1=",SS1," SS2=",SS2," BB1=",BB1," BB2=",BB2," V8=",Value8," V7=",Value7," V6=",Value6);
Print(" F=",Filled," P=",Position," MKP=",MKP);
RTime[7]=CurrentTime;
end;
 
 
             
        
         
         
         
     
     分類
    分類
 
            
4 評論