InputS: Length(50), Fcast(50);
InputS: FMode("Similarity"), CMode("Cumulative");
VAR: EvalWindowHigh(0), EvalWindowLow(0), RefWindowHigh(0), RefWindowLow(0);
VAR:CorrWindowHigh(0), CorrWindowLow(0), Correlation(0);
VAR: K(0), Alpha(0), Beta(0), E(0), Prev(0), Current(0);
VAR: A(0),B(0),X(0),D(0),I(0);
VAR: R(0),StandardDev(0),Covariance(0),BarNumber(0);
VAR: ShowArea(0);
// Initialize series for forecast and calculation windows
Array: A/ Cthe high and low of the evaluation window
EvalWindowHigh = Highest(High, Length + Fcast * 2);
EvalWindowLow = Lowest(Low, Length + Fcast * 2);
// Loop through and populate arrays for calculations
For I = 0 To Fcast * 2 + Length - 1 Begin
A[I] = Close[I];
If CMode = "Linreg" Then
X[I] = BarNumber[I];
End;
// Reference window
A[0] = A[Length];
// Calculate correlation
For I = 0 To Length - 1 Begin
B[I] = A[Fcast + I];
R = Covariance(A, B) / (StandardDev(A, Length) * StandardDev(B, Length));
// Maximize or minimize correlation based on FMode
If FMode = "Similarity" Then Begin
If R >= Correlation Then Begin
Correlation = R;
K = I;
End;
End
Else Begin
If R <= Correlation Then Begin
Correlation = R;
K = I;
End;
End;
End;
// Set ECHO forecast
Prev = Close;
Current = Close;
For I = 0 To Fcast - 1 Begin
E = D[Fcast + K + (Fcast - I - 1)];
// Calculate forecast point
If CMode = "Mean" Then
Current = Average(A, Fcast) + E;
Else If CMode = "Linreg" Then Begin
Alpha = Covariance(A, X) / Variance(X);
Beta = Average(A) - Alpha * Average(X);
Current = Alpha * (BarNumber + I + 1) + Beta + E;
End
Else
Current = Current + E;
Plot1(Current, "Forecast" + NumToStr(I, 0)); // Plot forecast
Prev = Current;
End;
// Optional: Visualize area for reference, evaluation, and correlation windows
If ShowArea Then Begin
// This part would involve drawing boxes or shaded areas on the chart
// EasyLanguage doesn't have a direct equivalent to boxes, so consider plotting lines or marks
End;
선행지표를 만들어볼려고 하는데 어렵네요. 도와주세여ㅠㅠ
답변 1
예스스탁
예스스탁 답변
2025-03-04 13:32:07
안녕하세요
예스스탁입니다.
올려주신 내용은 저희가 수정이 어렵습니다.
올리신 수식의 내용이 파악되지 않고
수식에 사용된 각 함수도 저희 언어와 매개변수들이 달라 수정해 드릴수 없습니다.
즐거운 하루되세요
> 만경 님이 쓴 글입니다.
> 제목 : 수식 변경 부탁드립니다.
> InputS: Length(50), Fcast(50);
InputS: FMode("Similarity"), CMode("Cumulative");
VAR: EvalWindowHigh(0), EvalWindowLow(0), RefWindowHigh(0), RefWindowLow(0);
VAR:CorrWindowHigh(0), CorrWindowLow(0), Correlation(0);
VAR: K(0), Alpha(0), Beta(0), E(0), Prev(0), Current(0);
VAR: A(0),B(0),X(0),D(0),I(0);
VAR: R(0),StandardDev(0),Covariance(0),BarNumber(0);
VAR: ShowArea(0);
// Initialize series for forecast and calculation windows
Array: A/ Cthe high and low of the evaluation window
EvalWindowHigh = Highest(High, Length + Fcast * 2);
EvalWindowLow = Lowest(Low, Length + Fcast * 2);
// Loop through and populate arrays for calculations
For I = 0 To Fcast * 2 + Length - 1 Begin
A[I] = Close[I];
If CMode = "Linreg" Then
X[I] = BarNumber[I];
End;
// Reference window
A[0] = A[Length];
// Calculate correlation
For I = 0 To Length - 1 Begin
B[I] = A[Fcast + I];
R = Covariance(A, B) / (StandardDev(A, Length) * StandardDev(B, Length));
// Maximize or minimize correlation based on FMode
If FMode = "Similarity" Then Begin
If R >= Correlation Then Begin
Correlation = R;
K = I;
End;
End
Else Begin
If R <= Correlation Then Begin
Correlation = R;
K = I;
End;
End;
End;
// Set ECHO forecast
Prev = Close;
Current = Close;
For I = 0 To Fcast - 1 Begin
E = D[Fcast + K + (Fcast - I - 1)];
// Calculate forecast point
If CMode = "Mean" Then
Current = Average(A, Fcast) + E;
Else If CMode = "Linreg" Then Begin
Alpha = Covariance(A, X) / Variance(X);
Beta = Average(A) - Alpha * Average(X);
Current = Alpha * (BarNumber + I + 1) + Beta + E;
End
Else
Current = Current + E;
Plot1(Current, "Forecast" + NumToStr(I, 0)); // Plot forecast
Prev = Current;
End;
// Optional: Visualize area for reference, evaluation, and correlation windows
If ShowArea Then Begin
// This part would involve drawing boxes or shaded areas on the chart
// EasyLanguage doesn't have a direct equivalent to boxes, so consider plotting lines or marks
End;
선행지표를 만들어볼려고 하는데 어렵네요. 도와주세여ㅠㅠ