Tuesday, February 28, 2017

bar object

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
ClearDebug();
PrintDebug("High " + Bars.High[Bars.Count - 1]);
PrintDebug("Low " + Bars.Low[Bars.Count - 1]);
PrintDebug("Open " + Bars.Open[Bars.Count - 1]);
PrintDebug("Close " + Bars.Close[Bars.Count - 1]);
//double range1 = Bars.High[Bars.Count - 1] - Bars.Low[Bars.Count - 1];
//PrintDebug("range " + range);

//double range1 = Bars.High[Bars.Count - 2] - Bars.Low[Bars.Count - 2];
//PrintDebug("range " + range);
const int period = 1;

double sum = 0d;
double r1 = 0d;

for(int bar = Bars.Count - 1; bar >= Bars.Count - period; bar--)    {
r1 = Bars.High[bar] - Bars.Low[bar];
PrintDebug("range " + r1);
sum = sum + Bars.Close[bar];

}
double avg = sum / period;
PrintDebug("The " + period + "-Period average is: " + avg);


}
}
}

No comments:

Post a Comment