Get history data from custom Indicator in OnStart
Get history data from custom Indicator in OnStart
19 Jan 2020, 19:51
Dear community,
I would like to get history data that I see on chart with Custom Indicator (https://ctrader.com/algos/indicators/show/111). OnStart method I would like to get last values from this Indicator.
I don't understand why the data that I print in logs are not the same as I see on the chart. As an example I am looking for all Major Sell or Buy signals.
As you see below, the MinorSell I should get at cycle.MinorSell.Last(4) and MajorSell at around Last(72). But the logs from below code shows different values compared to values seen on chart. What is more if I loop over all results, there are not possible data as sometimes DotsBuy and DotsSell are at the same time with value = 1. The dots are either Buy or Sell.
The endgame is to have opportunity to create a logic in cBot that after restart the cBot it can get the last Major signal (either it is sell or buy) based on history data from chart.
Please see below code.
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class aTestIndi : Robot
{
private CycleIdentifierAL cycle;
protected override void OnStart()
{
cycle = Indicators.GetIndicator<CycleIdentifierAL>(0, 0, 12, MovingAverageType.Simple, 21, 3, 1, 4);
for (int i = 0; i < 100; i++)
{
if (cycle.MajorSell.Last(i) == 1 || cycle.MajorBuy.Last(i) == -1)
{
Print(i);
Print("Date: " + MarketSeries.OpenTime.Last(i));
Print("cycle.Line.Last(" + i + "): " + cycle.Line.Last(i));
Print("cycle.MajorBuy.Last(" + i + "): " + cycle.MajorBuy.Last(i));
Print("cycle.MajorSell.Last(" + i + "): " + cycle.MajorSell.Last(i));
Print("cycle.MinorBuy.Last(" + i + "): " + cycle.MinorBuy.Last(i));
Print("cycle.MinorSell.Last(" + i + "): " + cycle.MinorSell.Last(i));
Print("cycle.DotsBuy.Last(" + i + "): " + cycle.DotsBuy.Last(i));
Print("cycle.DotsSell.Last(" + i + "): " + cycle.DotsSell.Last(i));
}
}
}
}
}
Hope you can find where is the fault at my side.
Replies
... Deleted by UFO ...
lukasztrader
22 Jan 2020, 20:47
RE:
kerrifox19 said:
Have you solved your issues?
Hi, not yet. Cannot resolve it and why what is the issue. Can you help?
@lukasztrader
lukasztrader
21 Jan 2020, 19:59
Dear community,
Is there anybody that could support me with this issue?
@lukasztrader