今日最大成交量的抓法?

  •   926 
  • 最後發表   奇怪的人  2022 四月 27
奇怪的人 發文於   2022/04/10

我想要抓取"今日"最大成交量的當根高低價區間

但是我只會寫出近X根K棒內的最大量的高低區間

如下

if highest(Volume[1],6) = Volume[1] then begin
if highest(open[1], 1) > highest(close[1], 1) then value11 = highest(open[1], 1) else value11 = highest(close[1], 1);
if lowest(open[1], 1) < lowest(close[1], 1) then value12 = lowest(open[1], 1) else value12 = lowest(close[1], 1);
end;

highest(Volume[1],6)的語法有什麼可以改?

 

//補-----------

if barfreq <> "MIN" and barinterval <> 5 then raiseruntimeerror("請使用5分鐘頻率"); 

if highest(Volume[1],6) = Volume[1] then begin 
if highest(open[1], 1) > highest(close[1], 1) then value11 = highest(open[1], 1) else value11 = highest(close[1], 1); 
if lowest(open[1], 1) < lowest(close[1], 1) then value12 = lowest(open[1], 1) else value12 = lowest(close[1], 1); 
end; 


if currenttime < 131500 and currenttime > 090500 then begin 
var:InCondition1(False); 
InCondition1 = close Crosses Above value11; 
if position = 0 and filled = 0 and InCondition1 then setposition(500/close,value11,label:="做多進場"); 
end; 

//-----------132450平倉----------- 
if filled <> 0 and currenttime > 132450 then setposition(0, market); 
//-----------出場-----------
input: profit_point(10, "停利(點)");
input: profit_drawback_point(5, "停利回跌(點)");
input: loss_point(10, "停損(點)");

var: long_condition(false);         { 進場買進作多 }
if profit_point = 0 then raiseruntimeerror("請設定停利(點)");
if profit_drawback_point = 0 then raiseruntimeerror("請設定停利回跌(點)");


if position > 0 and filled > 0 then begin 
    var: intrabarpersist max_profit_point(0);   { 啟動停利後最大獲利點 }

    if loss_point > 0 and Close <= FilledAvgPrice - loss_point then begin
        { 停損 }
        SetPosition(0);
        max_profit_point = 0;

    end else begin

        { 判斷是否要啟動停利 }
        if max_profit_point = 0 and Close >= FilledAvgPrice + profit_point then begin
            max_profit_point = Close;
        end;

        if max_profit_point <> 0 then begin       
            if Close <= max_profit_point - profit_drawback_point then begin
                { 停利 }
                SetPosition(0);
                max_profit_point = 0;
            end else if Close > max_profit_point then begin
                { 移動最大獲利點 }
                max_profit_point = Close;
            end;    
        end;        
    end;

end;

麻煩再幫我健檢一下這份

出現的問題是進場時間我希望是在090500~131500

不過也會有在這時間之外進場的

另外重點是我需要132450強制平倉

但在回測運行中也都沒有正確啟動

這部分也麻煩小幫手幫忙健檢一下

附加文件

排序方式: 標準 | 最新
GammaCEO 發文於   2022/04/11

試試看..不行再想其他語法

if barfreq <> "Min" or Barinterval <>5 then RaiseRuntimeError("請設定頻率為5分鐘");

setBackBar(54);

variable:BN(0);

if Date <> Date[1] then

BN=1

else

BN+=1;

if volume=highest(volume,BN) then

value1=high-low;

  • 按讚來自於
  • dick615106
貓老大 發文於   2022/04/11

試試這個方式

var: MaxVolume(0);
var: MaxVHigh(0), MaxVLow(99999);

if isSessionFirstBar then
 MaxVolume = 0;

if Volume > MaxVolume then
 begin
  MaxVolume = Volume;

  MaxVHigh = High;
  MaxVLow = Low;
 end;

// 此處可直接取用 MaxVHigh 跟 MaxVLow

 

奇怪的人 發文於   2022/04/11

專業級的

這我自己想破頭也弄不出來

感謝大大的幫忙

XQ小幫手 發文於   2022/04/15

Hello 奇怪的人,

 

您可以參考 GammaCEO 和 貓老大 的回覆。

另外,也可以參考 GetBarOffset 這個函數,此函數可以計算出與指定日期時間的相對位置。

關於 13:24:50 強制平倉的部分,由於XQ是有洗價才會運算,所以除非在 13:24:50 到 13:25:00 之間有洗價,不然腳本不會運算,無法確保一定會強制平倉。

小幫手會建議您留更多的時間來避免因為沒有洗價導致無法平倉的狀況發生。

至於進場的部分有幾種可能性,像是符合條件進場後,限價單掛在那邊沒有成交,直到時間區間外才成交。

或是該商品成交量很小,掛單後都沒有其他人交易直到時間區間外才有交易的話,都有可能導致在限制時間外才進場。

 

感謝 GammaCEO 和 貓老大 的熱心回覆。

奇怪的人 發文於   2022/04/20

if currenttime < 131500 and currenttime > 090500 then begin 
var:InCondition1(False),InCondition2(False),InCondition3(False); 
InCondition1 = close > 0 ; 
if position = 0 and filled = 0 and InCondition1 then setposition(200/close,addspread(value11, 1),label:="做多進場"); 
end; 

//-----------132000平倉----------- 
if filled <> 0 and currenttime >= 132000 then begin
  setposition(0, market);
  end;  

if position > 0 and filled > 0 then begin  
    if high >= addspread(filledavgprice, 5) then begin 
        setposition(0, addspread(filledavgprice, 5), label:="獲利出場"); 
        print("獲利出場", date, time, filledavgprice,addspread(filledavgprice, 5)); 
        end  
    else if low <= addspread(filledavgprice, -5)then begin 
        setposition(0, addspread(filledavgprice, -5), label:="虧損出場"); 
        print("虧損出場", date, time, filledavgprice, addspread(filledavgprice, -5)); 
        end; 
    end ;

如上

我想要進場張數壓在20萬內的最高張數

進場部位為value11指標+1TICK的價位買入進場

出場為入場價+5TICK獲利出場  ;  以及-5TICK虧損出場

132000強制平倉出場

不過目前遇到的問題是

我的+-5TICK獲利或虧損出場好像沒有確實運行

不知道是哪裡出了問題

XQ小幫手 發文於   2022/04/27

Hello 奇怪的人,

 

小幫手推測您應該是使用回測。

回測的出場價位只會在有成交量的OHLC上,且觸發條件後掛單,可以在更優價格出場。

舉例來說,如果您的出場價格是 賣出 565,而當下的價格是 566 的話,那麼就會以566成交,所以並不保證會成交在您的限價上。

 

發表回覆
Close