Нектодрон, подскажите пожалуйста для свечи [i-4]
нужно использовать:
list.Add(0);
for (int i = 4;
???
Работает, но у меня смещение на графике, не поможите?
Еще скажите пожалуйста, я правильно сформировал логику, в одном случае fr принимает значение high в другом low ???
Вот полный код:
using System.Collections.Generic;
using TSLab.Script;
using TSLab.Script.Handlers;
using TSLab.DataSource;
using TSLab.Script.Helpers;
namespace FractalSimple
{
public class Fractal_Simple : IBar2DoubleHandler, IContextUses
{
[HandlerParameter]
public int Period { get; set; }
public IList<double> Execute(ISecurity source)
{
var high = Context.GetData("Highest", new[] { Period.ToString() },
() => Series.Highest(source.HighPrices, Period));
var low = Context.GetData("Lowest", new[] { Period.ToString() },
() => Series.Lowest(source.LowPrices, Period));
var closes = source.ClosePrices;
double fr=0;
IList<double> list = new List<double>(closes.Count);
list.Add(0);
for (int i = 4; i < closes.Count; i++)
{
if((high[i-2] >= high[i-4]) && (high[i-2] >= high[i-3]) && (high[i-2] >= high[i-1]) && (high[i-2] > high[i]))
{
fr = high[i] ;
}
if((low[i-2] < low[i-4]) && (low[i-2] < low[i-3]) && (low[i-2] <= low[i-1]) && (low[i-2] < low[i]))
{
fr = low[i];
}
list.Add(fr);
}
return list;
}
public IContext Context { get; set; }
}
} Смещение

С
Заранее огромное спасибо!!!