abc889900 發表於 17-9-3 08:45

轉換為Powerlanguage 程式語言

以下是交易程式原始碼,可以幫忙轉換為Powerlanguage嗎?謝謝

VAR1:=((CLOSE - LLV(LOW,15))/(HHV(HIGH,15) - LLV(LOW,15)))*(100);
VAR2:=REVERSE(VAR1);
VAR3:=SMA(VAR1,5,1);
K:=SMA(VAR3,3,1);
D:=SMA(K,3,1);
DRAWTEXT(CROSS(K,D) AND MA(CLOSE,5)<CLOSE,D,'多'),COLORRED;
DRAWTEXT(CROSS(D,K) AND MA(CLOSE,5),D,'空'),COLORGREEN;
STICKLINE((K >= D),K,D,6,0),COLOR0000A8;
STICKLINE((K >= D),K,D,5,0),COLOR0000C0;
STICKLINE((K >= D),K,D,4,0),COLOR0000E0;
STICKLINE((K >= D),K,D,3,0),COLOR0000F0;
STICKLINE((K >= D),K,D,2,0),COLOR0000D0;
STICKLINE((K >= D),K,D,1,0),COLOR8080FF;
STICKLINE((K <= D),K,D,6,0),COLOR008800;
STICKLINE((K <= D),K,D,5,0),COLOR009900;
STICKLINE((K <= D),K,D,4,0),COLOR00AA00;
STICKLINE((K <= D),K,D,3,0),COLOR00BB00;
STICKLINE((K <= D),K,D,2,0),COLOR00CC00;
STICKLINE((K <= D),K,D,1,0),COLOR00DD00;
極端底部線:15;
極端頂部線:85

cowbearcar 發表於 17-10-16 08:40

本帖最後由 cowbearcar 於 17-10-16 08:42 編輯

input: len(15), avg1(5), avg2(3);
vars: upColour(red), downColour(green);

value1 = (Close - Lowest(Low, len))/(Highest(High, len) - Lowest(Low, len))*100;
value2 = AverageFC(value1, avg1);
value3 = AverageFC(value2, avg2);
value4 = AverageFC(value3, avg2);
value5 = AverageFC(value4, avg2);

Plot1(value4, "K");
Plot2(value5, "D");
Plot3(85, "85");
Plot4(15, "15");

if value4 > value5 {and AverageFC(Close, avg1) < Close} then
      SetPlotColor(1, upColour);
if value4 <= value5 {and AverageFC(Close, avg1) > Close} then
      SetPlotColor(1, downColour);
      

大致上做了,但上顏色就有點怪,已簡化。
頁: [1]
查看完整版本: 轉換為Powerlanguage 程式語言