Chart.ZoomLevel dis Chart.ScrollXTo ?
Chart.ZoomLevel dis Chart.ScrollXTo ?
30 Apr 2022, 22:54
Hi,
I encountered an interesting problem. One of my indicators needs to set the chart zoom level and Scroll bar a bit in the initialize(). The code works fine, when I switch TimeFrames away from the gap of Tick500 to Tick300, i.e. Tick300->Tick250 or to smaller. Tick500->Tick750 or larger, both scenarios are fine.
BUT, when the TimeFrame switch from Tick500->Tick300, the Chart.ScrollXTo doesn't work. And... Tick300->Tick500, the Chart.ZoomLevel seems 'destroyed' Chart.ScrollXTo.
I guess ScrollXTo is always operated before Chart.ZoomLevel change, no matter where I put the code before or after ZoomLevel change?
protected override void Initialize()
{
//Chart.ScrollXTo(Chart.FirstVisibleBarIndex - 5);
if (TimeFrame >= TimeFrame.Tick500) { Chart.ZoomLevel = 35; }
else if (TimeFrame < TimeFrame.Tick500) { Chart.ZoomLevel = 20; }
Chart.ScrollXTo(Chart.FirstVisibleBarIndex - 5);
Notifications.SendEmail("123@hotmail.com", "456@coldmail.com", "USD MORE Active" , "No Content"));
}
P.S. One little more question, if I put 'Notification.SendEmail' in the indicator's Initialize(), will the mail be sent? I checked the reference says Notification won't work in backtesting, but didn't mention about indicator Initialize().
Please help, much appreciated if any advice.
Thanks. :)
Replies
Capt.Z-Fort.Builder
02 May 2022, 13:14
RE:
OK, thanks. Though it's not a big issue.
amusleh said:
Hi,
It works fine, sometimes ScrollXTo and ZoomLevel can cause chart reload due to lack of data, and that will re-initialize your indicator.
Notifications only work on live environment, not in back test.
@Capt.Z-Fort.Builder
amusleh
02 May 2022, 08:53
Hi,
It works fine, sometimes ScrollXTo and ZoomLevel can cause chart reload due to lack of data, and that will re-initialize your indicator.
Notifications only work on live environment, not in back test.
@amusleh