Рассмотрим пример прорисовки в индикаторе собственного набора данных, который был рассчитан в роботе.
Для размещения своих данных на серии индикатора нужно использовать «Пустой индикатор». Он находится здесь:
В нём есть только одна серия данных, никаких расчётов внутри не ведётся.
КОД
[Indicator("EmptyIndicator")]
public class EmptyIndicator : Aindicator
{
private IndicatorDataSeries _series;
public override void OnStateChange(IndicatorState state)
{
if (state == IndicatorState.Configure)
{
_series = CreateSeries("Series", Color.DarkGreen, IndicatorChartPaintType.Point, true);
_series.CanReBuildHistoricalValues = true;
}
}
public override void OnProcess(List<Candle> candles, int index)
{
// do nothing
}
}КОНЕЦ КОДА
На гитХаб исходник примера находится здесь:
Внутри проекта:
КОД
[Bot("CustomDataInIndicatorSample")]
public class CustomDataInIndicatorSample : BotPanel
{
private BotTabSimple _tab;
private Aindicator _indicatorEmpty;
public CustomDataInIndicatorSample(string name, StartProgram startProgram) : base(name, startProgram)
{
TabCreate(BotTabType.Simple);
_tab = TabsSimple[0];
_tab.CandleFinishedEvent += _tab_CandleFinishedEvent;
_indicatorEmpty = IndicatorsFactory.CreateIndicatorByName("EmptyIndicator", name + "EmptyIndicator", false);
_indicatorEmpty = (Aindicator)_tab.CreateCandleIndicator(_indicatorEmpty, "SecondArea");
Description = "An example of drawing a series of indicator data calculated in the robot.";
}
private void _tab_CandleFinishedEvent(List<Candle> candles)
{
decimal dataPoint = candles[candles.Count - 1].Close / 2;
_indicatorEmpty.DataSeries[0].Values[_indicatorEmpty.DataSeries[0].Values.Count-1] = dataPoint;
_indicatorEmpty.RePaint();
}
public override string GetNameStrategyType()
{
return "CustomDataInIndicatorSample";
}
public override void ShowIndividualSettingsDialog()
{
}
}КОНЕЦ КОДА
Выглядеть в итоге это всё будет так:
Комментарии открыты для друзей!
Гайд: https://smart-lab.ru/company/os_engine/blog/1024149.php
OsEngine: https://github.com/AlexWan/OsEngine
Поддержка OsEngine: https://t.me/osengine_official_support