XS array_Sort 自動排序PLOT價位名該價位對應的名稱

  •   245 
  • 最後發表   XQYi  2024 四月 19
XQYi 發文於   2024/04/18

XS如何自動排序plot價位? - XQ全球贏家官方論壇

我處理好了價位排序問題,但

1. 價位排序後與原名稱對應不上,如何處置讓排序後的價位也能對應名稱?

2.當日的線型和價位仍無出現,如何處置?

var:a1(0),a2(0),a3(0),a4(0),a5(0),a6(0),a7(0),a8(0),a9(0);

a1=average(getField("收盤價","W"),5);

a2=xf_EMA("w",getField("收盤價","W"),12) ;

a3=xf_EMA("W",getField("收盤價","W"),26) ;

a4=average(getField("收盤價","W"),60);

a5=average(Close,5);

a6=EMA( Close,12) ;

a7=EMA( Close,26) ;

a8=average(Close,60);

a9=close;

array: sort[9](0);

sort[1]=a1;

sort[2]=a2;

sort[3]=a3;

sort[4]=a4;

sort[5]=a5;

sort[6]=a6;

sort[7]=a7;

sort[8]=a8;

sort[9]=a9;

value15=getField("漲停價", "D");

value16=getField("跌停價", "D");

value19=getField("控盤者成本線");

array_Sort(sort,1,9,False);

if a1 <value15 and a1 >value16 then  plot1(sort[1],"w5",checkbox:=0);

if a2 <value15 and a2 >value16 then plot2(sort[2],"w12",checkbox:=0);

if a3 <value15 and a3 >value16 then plot3(sort[3],"w26",checkbox:=0);

if a4 <value15 and a4 >value16 then plot4(sort[4],"w60",checkbox:=0);

if a5 <value15 and a5 >value16 then plot5(sort[5],"d5",checkbox:=0);

if a6 <value15 and a6 >value16 then plot6(sort[6],"d12",checkbox:=0);

if a7 <value15 and a7 >value16 then plot7(sort[7],"d26",checkbox:=0);

if a8 <value15 and a8 >value16 then plot8(sort[8],"d60",checkbox:=0);

plot9(sort[9],"收",checkbox:=0);

if value19 <value15 and value19 >value16 then plot16(value19,"成本線",checkbox:=0);

 

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

Plot的標題參數只能使用字串,若要配合變數處理,必須改用SetPlotLabel函數處理。

XQYi 發文於   2024/04/18

Dear 

 將

plot1(sort[1],"w5",checkbox:=0);

plot1(sort[1],checkbox:=0);

setplotLabel(1,"w5");

如果是這樣並不是所需

因為排序後的sort[1]不在是a1,資料有可能是另外幾個a2-a9的其中一個價位

虎科大許教授 發文於   2024/04/18

以下程式沒經過驗證,你驗證看看。

var:a1(0),a2(0),a3(0),a4(0),a5(0),a6(0),a7(0),a8(0),a9(0);

var:i(0);

array: Arr[9,2](0);

array: strArr[9]("");

a1=average(getField("收盤價","W"),5);

a2=xf_EMA("w",getField("收盤價","W"),12) ;

a3=xf_EMA("W",getField("收盤價","W"),26) ;

a4=average(getField("收盤價","W"),60);

a5=average(Close,5);

a6=EMA( Close,12) ;

a7=EMA( Close,26) ;

a8=average(Close,60);

a9=close;

 

arr[1,1]=a1;//"w5"

arr[2,1]=a2;//"w12"

arr[3,1]=a3;//"w26"

arr[4,1]=a4;//"w60"

arr[5,1]=a5;//"d5"

arr[6,1]=a6;//"d12"

arr[7,1]=a7;//"d26"

arr[8,1]=a8;//"d60"

arr[9,1]=a9;//"收"

arr[1,2]=1;

arr[2,2]=2;

arr[3,2]=3;

arr[4,2]=4;

arr[5,2]=5;

arr[6,2]=6;

arr[7,2]=7;

arr[8,2]=8;

arr[9,2]=9;

array_sort2d(arr, 1, 9, 1, false);

for i=1 to 9

begin

switch(Arr[i,2])

begin

case 1:

strArr[i]="w5";

case 2:

strArr[i]="w12";

case 3:

strArr[i]="w25";

case 4:

strArr[i]="w60";

case 5:

strArr[i]="d5";

case 6:

strArr[i]="d12";

case 7:

strArr[i]="d25";

case 8:

strArr[i]="d60";

case 9:

strArr[i]="收";

end;

end;

value15=getField("漲停價", "D");

value16=getField("跌停價", "D");

value19=getField("控盤者成本線");

if a1 <value15 and a1 >value16 then  

plot1(Arr[1,1],checkbox:=0);

setplotLabel(1,strArr[1]);

if a2 <value15 and a2 >value16 then 

plot2(Arr[2,1],checkbox:=0);

setplotLabel(2,strArr[2]);

if a3 <value15 and a3 >value16 then 

plot3(Arr[3,1],checkbox:=0);

setplotLabel(3,strArr[3]);

if a4 <value15 and a4 >value16 then 

plot4(Arr[4,1],checkbox:=0);

setplotLabel(4,strArr[4]);

if a5 <value15 and a5 >value16 then 

plot5(Arr[5,1],checkbox:=0);

setplotLabel(5,strArr[5]);

if a6 <value15 and a6 >value16 then 

plot6(Arr[6,1],checkbox:=0);

setplotLabel(6,strArr[6]);

if a7 <value15 and a7 >value16 then 

plot7(Arr[7,1],checkbox:=0);

setplotLabel(7,strArr[7]);

if a8 <value15 and a8 >value16 then 

plot8(Arr[8,1],checkbox:=0);

setplotLabel(8,strArr[8]);

plot9(Arr[9,1],checkbox:=0);

setplotLabel(9,strArr[9]);

if value19 <value15 and value19 >value16 then 

plot16(value19,"成本線",checkbox:=0);

  • 按讚來自於
  • b24524658
XQYi 發文於   2024/04/19

Dear

感謝您,經驗證是符合所需的,附上執行結果,再次由衷感謝!

發表回覆
Close