Convert code 2 VB.NET or C#

Dears,
Need your help to convert the following code to Dot.net
thanks in advcance

function TsimpleFunctionSet.dsSineWeightedMoveAverage(DataArray: IDataStream;Periods: Integer): TExprData;
var I: Integer;
ExprData: TExprData;
Num, Denum: Double;
SinVal: Double;

begin
Result.value := 0;
Result.isNull := False;
if Periods < 1 then
Result.isNull := True
else
begin
Num := 0;
DeNum := 0;
for I := 0 to Periods - 1 do
begin
ExprData := DataArray.GetPrev(I);
if ExprData.isNull then
begin
Result.isNull := True;
Break;
end;
SinVal := Sin(DegToRad((I + 1) * 180 / 6));
Num := Num + SinVal * ExprData.value;
DeNum := DeNum + SinVal;
end;
if DeNum <> 0 then
begin
if not Result.IsNull then
Result.Value := Num / DeNum;
//end if
end //if
else
result.isNull := True;
//end else
end;
end;

function TsimpleFunctionSet.dsEndPointMoveAverage(DataArray: IDataStream;
Periods: Integer): TExprData;
var
ExprData: TExprData;
// Sum: Double;
S1, S2: Double;
I: Integer;
begin
Result.value := 0;
Result.isNull := False;
if Periods < 1 then
Result.isNull := True
else
begin
S1 := 0;
S2 := 0;
for I := 0 to Periods - 1 do
begin
if i = 0 then
ExprData := DataArray.getCurrent
else
ExprData := DataArray.GetPrev(I);
//end if

if ExprData.isNull then
begin
Result.isNull := True;
Break;
end;

S1 := S1 + (2 * Periods - (1 + i * 3)) * ExprData.value;
S2 := S2 + (2 * Periods - (1 + i * 3));
end; //for
if not Result.isNull then
Result.value := S1 / S2;
end;
end;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories