Chart.ScrollXTo crash
Chart.ScrollXTo crash
05 Aug 2022, 15:45
Hi,
When I call Chart.ScrollXTo passing it a date before Bars[Chart.FirstVisibleBarIndex].OpenTime the method crashes (or at least the indicator is restarted). So i tried this code but my indicator restarts anyway:
while (date < Bars[Chart.FirstVisibleBarIndex].OpenTime)
{ Bars.LoadMoreHistory();}
Chart.ScrollXTo(date);
All of this happens in live mode. How do I load the missing bars first and then scroll without the user intervention?
What did I do wrong? Thank you
Replies
rick779
05 Aug 2022, 16:14
RE:
PanagiotisCharalampous said:
Hi Riccardo,
Can you please share the complete code of the indicator you are using?
Best Regards,
Panagiotis
https://drive.google.com/file/d/1l-z242XocrMB3tNZc6_llhzGKFtYwgvb/view?usp=sharing
Thanks
@rick779
PanagiotisCharalampous
05 Aug 2022, 16:21
Hi Riccardo,
I tried this but I do not understand what the problem is. Can you explain?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
rick779
05 Aug 2022, 16:31
RE:
PanagiotisCharalampous said:
Hi Riccardo,
I tried this but I do not understand what the problem is. Can you explain?
Best Regards,
Panagiotis
I would like to scroll to a time position that is currently unavailable because the date precedes Bars[Chart.FirstVisibleBarIndex].OpenTime. In this case, if I call Chart.ScrollTo(date) the indicator is restarted. So I tried calling Bars.LoadMoreHistory() first, but it seems that even this call alone causes the indicator to restart. Thank you
@rick779
PanagiotisCharalampous
05 Aug 2022, 16:38
Hi Riccardo,
In this case, if I call Chart.ScrollTo(date) the indicator is restarted. So I tried calling Bars.LoadMoreHistory() first, but it seems that even this call alone causes the indicator to restart.
Can you explain how did you come to this conclusion? What do I need to do to observe such a behavior?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
rick779
05 Aug 2022, 17:27
( Updated at: 05 Aug 2022, 17:40 )
RE:
PanagiotisCharalampous said:
Hi Riccardo,
In this case, if I call Chart.ScrollTo(date) the indicator is restarted. So I tried calling Bars.LoadMoreHistory() first, but it seems that even this call alone causes the indicator to restart.Can you explain how did you come to this conclusion? What do I need to do to observe such a behavior?
Best Regards,
Panagiotis
I have simplified the code to give a demonstration thanks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(AccessRights = AccessRights.FullAccess, IsOverlay = true)]
public class NewIndicator : Indicator
{
protected override void Initialize()
{
Print("STARTED");
Chart.KeyDown += Chart_KeyDown;
}
private void Chart_KeyDown(ChartKeyboardEventArgs obj)
{
if (obj.Key == Key.Z)
Scroll();
}
void Scroll()
{
Print("SCROLL");
DateTime date = Bars[Chart.FirstVisibleBarIndex].OpenTime.AddYears(-1);
//NOT WORKING
//while (date < Bars[Chart.FirstVisibleBarIndex].OpenTime)
//{
// Bars.LoadMoreHistory(); // crash
//}
Chart.ScrollXTo(date); // crash
}
public override void Calculate(int index)
{
}
}
}
@rick779
PanagiotisCharalampous
05 Aug 2022, 15:52
Hi Riccardo,
Can you please share the complete code of the indicator you are using?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous