目前的語法是寫將 時間判斷式 寫在最後面的condition,
//程式開始
if barfreq <> "Min" or Barinterval <>1 then RaiseRuntimeError("請設定頻率為1分鐘");
if GetSymbolInfo("買賣現沖")=false and GetSymbolInfo("先買現沖")=false then return;
宣告變數 參數
condition1
condition2
........
condition99=time>=092900 and time<=115900;
if condition1 and condition2 and condition3 and .......and condition99 then setpostion()
if position<>0 and condition then 出場
如果改成 開頭用用判斷式,時間符合才開始判斷,比較不會占用程式效能?因為怕同時間有太多程式在執行,不想時間不符合的程式浪費太多資源,但也不想要時間到了再開啟程式,怕有問題影響執行中的程式,想要開盤前就全部開好。
// 程式開始
if time>=092900 and time<=115900 then begin
if barfreq <> "Min" or Barinterval <>1 then RaiseRuntimeError("請設定頻率為1分鐘");
if GetSymbolInfo("買賣現沖")=false and GetSymbolInfo("先買現沖")=false then return;
宣告變數 參數
condition1
condition2
........
if condition1 and condition2 and condition3 and .......and condition99 then setpostion()
end
if position<>0 and condition then 出場 // 寫在 if begin的外層,因為停損條件直到收盤
感恩回覆~
7 評論