[TS懶人包] [保險服務]

2009年5月18日 星期一

HTS NRTR 轉 TradeStation

這個函數在之前就有轉過到 TradeStation 上使用過…要從 HTS 裡拿到 TradeStation 上來用…需要自己新增數個函式…這邊就把這些函式貼給大家參考一下吧。

以下是新增的function名稱和程式內容:

IntraDayMultipier

IntraDayMultipier = 1;

If DataCompression = 1 Then
IntraDayMultipier = SquareRoot( 360 / BarInterval * 60);


HighestValue

input : dArray(Numeric), Length(Numeric);
Variables : ii(0);

Value1 = dArray;
For ii = 2 To Length begin
If Value1 < dArray[ii-1] Then
Value1 = dArray[ii-1];
End;
HighestValue = Value1;


LowestValue

input : dArray(Numeric), Length(Numeric);
Variables : ii(0);

Value1 = dArray;
For ii = 2 To Length begin
If Value1 > dArray[ii-1] Then
Value1 = dArray[ii-1];
End;
LowestValue = Value1;


最後就是 NRTR 這個 function

input:K(Numeric), Max_per(Numeric);
Variables: Trend(Close), Period(0);

Value1 = IntraDayMultipier;

Condition1 = (Close >= Trend);
Condition2 = (Close < Trend);

If ((Close Cross over Trend) or (Close Cross Below Trend)) Then
Period = 0;

If Period < Max_per Then begin
If Condition1 Then begin
Period = Period + 1;
Trend = HighestValue(Close, Period) * (1 - (K / 100) / Value1);
End;
If Condition2 Then begin
Period = Period + 1;
Trend = LowestValue(Close, Period) * (1 + (K / 100) / Value1);
End;
end
Else begin
If Condition1 Then
Trend = HighestValue(Close, Max_per) * (1 - (K / 100) / Value1);
If Condition2 Then
Trend = LowestValue(Close, Max_per) * (1 + (K / 100) / Value1);
End;

NRTR = Trend;


這個函式似乎不少人使用…給大家參考一下。

沒有留言:

張貼留言

請留下您的大名…匿名者恕不回應…

Related Posts Plugin for WordPress, Blogger...