想寫一個策略與量積木一樣的邏輯
盤中符合全部條件
執行時段為9點30分到12點整
最新價<當日均價線0%以上
成交量>= 2000張
長上影線,上影線幅度超過2%
連續3分鐘大戶持續賣超
目前腳本寫成
{@type:strategy}
// 腳本類型: 策略
// 腳本名稱: 綜合條件策略
// 顯示名稱: 綜合條件策略
// 執行頻率: 1分(非逐筆洗價)
// ========== 參數定義 ==========
Input: priceDeviation(0), volumeLimit(2000), shadowThreshold(2), bigOrderSide(-1);
// ========== 變數定義 ==========
Var: priceCondition(false), volumeCondition(false), shadowCondition(false), bigOrderCondition(false), overallCondition(false);
// ========== 條件一:最新價小於均價線 ==========
SetTotalBar(2);
Var: lastPrice(0), averagePrice(0);
lastPrice = GetField("收盤價");
averagePrice = GetField("均價");
if lastPrice < averagePrice * (1 - (priceDeviation / 100)) then priceCondition = true;
// ========== 條件二:成交量大於等於2000張 ==========
SetTotalBar(1);
if GetField("成交量", "D")[0] >= volumeLimit then volumeCondition = true;
// ========== 條件三:長上影線判斷 ==========
SetBackBar(10, "D");
Var: highPrice(0), bodyReference(0);
highPrice = GetField("最高價", "D");
bodyReference = maxList(GetField("開盤價", "D"), GetField("收盤價", "D"));
if (highPrice - bodyReference) > GetField("收盤價", "D")[1] * shadowThreshold * 0.01 and
(GetField("開盤價", "D") - GetField("收盤價", "D")) < (highPrice - bodyReference) then shadowCondition = true;
// ========== 條件四:大戶持續賣超 ==========
SetTotalBar(3);
Var: orderSellVolume(0), orderBuyVolume(0), netBigOrders(0);
orderSellVolume = GetField("賣出特大單量") + GetField("賣出大單量");
orderBuyVolume = GetField("買進特大單量") + GetField("買進大單量");
netBigOrders = bigOrderSide * (orderBuyVolume - orderSellVolume);
if netBigOrders > 0 then bigOrderCondition = true;
// ========== 綜合條件判斷 ==========
overallCondition = priceCondition and volumeCondition and shadowCondition and bigOrderCondition;
// ========== 警示腳本 ==========
if overallCondition then
ret = 1;
回測不來與量化積木不太一樣
同一檔標的會重複進場
1 評論