Download MetaTrader 5
To add comments, please log in or register
Do you need private account monitoring? The Signals will provide you one!
sunshineh
1064
sunshineh 2012.02.09 22:05 

Hi,

I have programmed an indicator and wrote a few labels on the right. Can I program a definite chart shift for my indicator?

whroeder1
13613
whroeder1 2012.02.09 23:27  
doubt it. Let the user determine what is appropriate.
qjol
3243
qjol 2012.02.10 00:22  
PostMessageA(GetAncestor(WindowHandle(Symbol(),Period()),2),WM_COMMAND,33023,0);
whroeder1
13613
whroeder1 2012.02.10 15:45  
qjol:
That just turns on/off the shift. The OP asked for "program a definite chart shift" i.e. control the amount.
sunshineh
1064
sunshineh 2012.02.11 09:45  

Thank you!

@WHRoeder: As I see, the user can't determine what is appropriate. The user can only switch the chart shift on or off.

When I want only to write one value on the right of the chart I find the fixed chart shift is too much.

Daniel Petrovai
440
Daniel Petrovai 2014.03.01 01:14  

There is a way to shift the chart now.

Add this 2 functions to your indicator :

//+---------------------------------------------------------------------------+
//| The function receives shift size of the zero bar from the right border    |
//| of the chart in percentage values (from 10% up to 50%).                   |
//+---------------------------------------------------------------------------+
double ChartShiftSizeGet(const long chart_ID=0)
  {
//--- prepare the variable to get the result
   double result=EMPTY_VALUE;
//--- reset the error value
   ResetLastError();
//--- receive the property value
   if(!ChartGetDouble(chart_ID,CHART_SHIFT_SIZE,0,result))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
     }
//--- return the value of the chart property
   return(result);
  }
//+--------------------------------------------------------------------------------------+
//| The function sets the shift size of the zero bar from the right                      |
//| border of the chart in percentage values (from 10% up to 50%). To enable the shift   |
//| mode, CHART_SHIFT property value should be set to                                    |
//| true.                                                                                |
//+--------------------------------------------------------------------------------------+
bool ChartShiftSizeSet(const double value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetDouble(chart_ID,CHART_SHIFT_SIZE,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
//+------------------------------------------------------------------+

Then use this :

if(ChartShiftSizeGet()<ChartShift)ChartShiftSizeSet(ChartShift);

Where ChartShift value is set by user ( between 10% and 50%).

extern int ChartSift = 20;
/
To add comments, please log in or register