PDA

View Full Version : MultiTimeFrameSMA


TheChingachgook
01-21-2010, 06:36 AM
The SMA of the 15 min timeframe in a 5 min chart doesn't look correct.

Are there any problems in my code?

protected override void Initialize()
{

Add(PeriodType.Minute, 15);
Add(PeriodType.Minute, 30);
Add(PeriodType.Minute, 60);
Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA5"));
Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA15"));
Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA30"));
Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA60"));


CalculateOnBarClose = true;
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
SMA5.Set(SMA(period)[0]);
SMA15.Set(SMA(BarsArray[1], period)[0]);
SMA30.Set(SMA(BarsArray[2], period)[0]);
SMA60.Set(SMA(BarsArray[3], period)[0]);
}



http://img705.imageshack.us/img705/4052/rl5min20012010.jpg

TheChingachgook
01-21-2010, 07:14 AM
... found it out in the meantime

the problem was not the SMA of the 15 min, the problem was the 5 min itself

After changing the code to

SMA5.Set(SMA(BarsArray[0],period)[0]);

now it works