Chart-Shift of an indicator

 

Hi,

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

 
doubt it. Let the user determine what is appropriate.
 
PostMessageA(GetAncestor(WindowHandle(Symbol(),Period()),2),WM_COMMAND,33023,0);
 
qjol:
That just turns on/off the shift. The OP asked for "program a definite chart shift" i.e. control the amount.
 

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.

 

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;