Trying to write a script to scroll a chart continuously. Beginning with a pause of 5 seconds. Not sure if this is the right direction. Could someone tell me if this code is the right way to accomplish this?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Trying to write a script to scroll a chart continuously. Beginning with a pause of 5 seconds. Not sure if this is the right direction. Could someone tell me if this code is the right way to accomplish this?
Thanks!
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
long handle=ChartID(), first_bar;
int Counted_bars=IndicatorCounted();
int i=Bars-Counted_bars-1;
if(handle>0)
{
ChartSetInteger(handle,CHART_AUTOSCROLL,false);
ChartSetInteger(handle,CHART_SHIFT,true);
ChartSetInteger(handle,CHART_MODE,CHART_CANDLES);
Sleep(5000);
while(i>=0)
{
ChartNavigate(handle,CHART_END,-1);
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
}
i--;
}
}