Scrolling Charts

Back to topics list To post a new topic, please log in or register
avatar
186
Yellowbeard 2016.04.29 16:18
 

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--;
      
      }   
     
      }
avatar
13001
WHRoeder 2016.04.29 20:25 #
 
  1. Don't double post
  2. int Counted_bars=IndicatorCounted();      
    Scripts are not indicators.
  3. Why do you have a loop when nothing inside depends on i? And you don't change i so you have an infinite loop.
avatar
186
Yellowbeard 2016.04.29 21:04 #
 
Continuous scrolling of charts doesn't require loop?
avatar
13001
WHRoeder 2016.04.29 21:36 #
 
Yellowbeard: Continuous scrolling of charts doesn't require loop?
It doesn't require code, at all. Turn on autoscroll

avatar
186
Yellowbeard 2016.04.29 21:50 #
 
Thanks!  This I know.  I'm looking for continuous scroll, in the opposite direction.
avatar
13001
WHRoeder 2016.04.29 22:13 #
 
Yellowbeard: I'm looking for continuous scroll, in the opposite direction.
Control-Home

avatar
186
Yellowbeard 2016.04.29 22:39 #
 
Thanks, again!  Now, by incremental step.   Not jump to end.  Candle by candle. Period by period.
avatar
69
Tecuciztecatl 2016.04.29 23:27 #
 

I think you want something like that)

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
   {
                                                        
      int i=Bars;                                                                     

      ChartSetInteger(0,CHART_AUTOSCROLL,false);
      ChartSetInteger(0,CHART_SHIFT,true);
      ChartSetInteger(0,CHART_MODE,CHART_CANDLES);
      
      while(i>=0)                                                                             
         {
         ChartNavigate(0,CHART_CURRENT_POS,-1);
         Sleep(50);
         if(IsStopped()) break;
         i--;
         } 
   }

 

avatar
13001
WHRoeder 2016.04.30 13:55 #
 
Yellowbeard: Now, by incremental step.   Not jump to end.  Candle by candle. Period by period.
Fast Navigation - User Interface - MetaTrader 4 Help
Back to topics list  

To add comments, please log in or register