今日量大過前3天(或前N天)最大黑K量

  •   115 
  • 最後發表   andrew1234  2024 十月 15
andrew1234 發文於   2024/07/10

請問各位大大,土法煉鋼的寫法如下,N較大時有沒有比較好的寫法?謝謝

if C[1]<O[1] then value1=V[1] else value1=0 ;

if C[2]<O[2] then value2=V[2] else value2=0 ;

if C[3]<O[3] then value3=V[3] else value3=0 ;

condition1=v>value1;

condition2=v>value2;

condition3=v>value3;

if condition1 and condition2 and condition3 then ret=1;

排序方式: 標準 | 最新
虎科大許教授 發文於   2024/07/10

今天量大過前三天最大黑K量:

value1=highest(v[1],3);

value2=highestBar(v[1],3);

if C[value2+1]<O[value2+1] and v>value1 then ret=1; 

  • 按讚來自於
  • LIUANDREW
鍵盤上的小白兔 發文於   2024/07/10

我也試寫一個

選出股數和許教授不一樣

重看了一下題目    感覺中文真深奧

最大黑K量

(A)黑K中 , 量最大的

(B)跌幅最大的黑K , 它的量

2個有不同答案 

  • 按讚來自於
  • LIUANDREW
andrew1234 發文於   2024/07/10

感謝指導,可能表達有點問題,我原本的想法是想指A:黑K中,量最大的

謝謝~

鍵盤上的小白兔 發文於   2024/07/10

可以試看看 , 是否是你想要的

 

input:ND(3,"今日成交量大於N日的黑K最大量");

var:BigVolume(0);

var:i(0);

 

if islastBar=true then

  begin

    for i=1 to ND 

      begin

        if c[i]<o[i] and v[i]>BigVolume then

        Bigvolume=v[i];

      end;

    

    if BigVolume<>0 and v>BigVolume then

      ret=1;  

  end;

  • 按讚來自於
  • LIUANDREW
andrew1234 發文於   2024/07/10

應該就是我想要的,也是想說要試試迴圈,但寫不出來,感謝!!

虎科大許教授 發文於   2024/10/15

很多程式其實不需要跑迴圈。這個需求可以更有效率的處理。

 

input: ND(3,"今日成交量大於N日前的黑K最大量");

setTotalBar(ND+1);

var: BigVolume(0);

if isLastBar=false then

     begin

        if c<o and v>BigVolume then BigVolume=v;

     end

else 

        if BigVolume<>0 and v>BigVolume then ret=1;

  • 按讚來自於
  • kidechang
發表回覆
Close