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

 

hi

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

 
Documentation on MQL5: Chart Operations / ChartNavigate
Documentation on MQL5: Chart Operations / ChartNavigate
  • www.mql5.com
Chart Operations / ChartNavigate - Reference on algorithmic/automated trading language for MetaTrader 5
 

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. 

 
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);
  }
//+------------------------------------------------------------------+

 
Ernst Van Der Merwe:

It's missing two other function calls.


Did not fix it
 
// Chart position
        ChartSetInteger(ChartID(),CHART_AUTOSCROLL,true);
        ChartSetInteger(ChartID(),CHART_SHIFT,true); 
        ChartSetDouble(0, CHART_SHIFT_SIZE, 22); //distance from right border
 
  trexnft pivx #:
very nice! just want I want!. It worked.