" Shift end of the chart from right border" in EA?

Reza nasimi  

hi

how to do " Shift end of the chart from right border"  in EA?

Essam Daoud  

Hi

This mql5 code is not Shifting end of the chart from the right boarder. Any idea how2 get it done? Thank you


int OnInit() {
  //--- chart positioning
  ChartNavigate(0, CHART_END, 33);


The code is expected to place a distance of 33 bars between the right boarder of the chart and the latest price bar. But is not do it. 

Ernst Van Der Merwe  
samjesse:

Hi

This mql5 code is not Shifting end of the chart from the right boarder. Any idea how2 get it done? Thank you



The code is expected to place a distance of 33 bars between the right boarder of the chart and the latest price bar. But is not do it. 

It's missing two other function calls.

int OnInit() {
  //--- chart positioning
  ChartSetInteger(ChartID(),CHART_AUTOSCROLL,false);
  ChartSetInteger(ChartID(),CHART_SHIFT,false); 
  ChartNavigate(0, CHART_END, 33);

Edit:

Can't shift back further than CHART_END, it seems.

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
  ChartSetInteger(ChartID(),CHART_AUTOSCROLL,false);
  ChartSetInteger(ChartID(),CHART_SHIFT,false); 
  ChartNavigate(ChartID(), CHART_END, -33);
  Sleep(1000);
  ChartNavigate(ChartID(), CHART_END,  66);
  }
//+------------------------------------------------------------------+

Essam Daoud  
Ernst Van Der Merwe:

It's missing two other function calls.


Did not fix it
trexnft pivx  
// Chart position
        ChartSetInteger(ChartID(),CHART_AUTOSCROLL,true);
        ChartSetInteger(ChartID(),CHART_SHIFT,true); 
        ChartSetDouble(0, CHART_SHIFT_SIZE, 22); //distance from right border
Reason: