//+------------------------------------------------------------------+ //| GetNextBar.mqh | //| Copyright 2014, //| http://www | //+------------------------------------------------------------------+ #property copyright "Copyright 2014" #property link "http://www" int GetChartW(){ int ChartW = ChartWidthInBars(); if (ChartShiftGet()){ double ShiftMargin = ChartShiftSizeGet(); if (ShiftMargin > 0) ChartW = (int)MathRound((100.0 - ShiftMargin)*ChartW/100.0); } return ChartW; } int GetNextBar(int Shift = 0){ //Zwraca nr ostatniego widocznego po prawej BAR'a. Shift -> RIGTH int MinBar = ChartFirstVisibleBar(); int ChartW = ChartWidthInBars(); if (ChartShiftGet()){ double ShiftMargin = ChartShiftSizeGet(); if (ShiftMargin > 0) ChartW = (int)MathRound((100.0 - ShiftMargin)*(double)ChartW/100.0); } int MaxBar = MinBar - ChartW; MaxBar = MaxBar - Shift; if (MaxBar < 0) MaxBar = 0; return(MaxBar); } int ChartShiftInBars(){ int ChartW = ChartWidthInBars(); int Result = 0; if (ChartShiftGet()){ double ShiftMargin = ChartShiftSizeGet(); if (ShiftMargin > 0) Result = (int)MathRound(ShiftMargin*(double)ChartW/100.0); } return Result; } int ChartFirstVisibleBar(const long chart_ID=0) { //--- prepare the variable to get the property value long result=-1; //--- reset the error value ResetLastError(); //--- receive the property value if(!ChartGetInteger(chart_ID,CHART_FIRST_VISIBLE_BAR,0,result)) { //--- display the error message in Experts journal Print(__FUNCTION__+", Error Code = ",GetLastError()); } //--- return the value of the chart property return((int)result); } int ChartWidthInBars(const long chart_ID=0) { //--- prepare the variable to get the property value long result=-1; //--- reset the error value ResetLastError(); //--- receive the property value if(!ChartGetInteger(chart_ID,CHART_WIDTH_IN_BARS,0,result)) { //--- display the error message in Experts journal Print(__FUNCTION__+", Error Code = ",GetLastError()); } //--- return the value of the chart property return((int)result); } 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); } bool ChartShiftGet(const long chart_ID=0) { //--- prepare the variable to get the property value long value; //--- reset the error value ResetLastError(); //--- receive the property value if(!ChartGetInteger(chart_ID,CHART_SHIFT,0,value)) { //--- display the error message in Experts journal Print(__FUNCTION__+", Error Code = ",GetLastError()); return(false); } //--- store the value of the chart property in memory //result=value; //--- successful execution if (value > 0) return(true); else return(false); }