Convert code 2 VB.NET or C# - Programmers Heaven

#### Howdy, Stranger!

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

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Convert code 2 VB.NET or C#

Posts: 1Member
Dears,
Need your help to convert the following code to Dot.net

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;