bool Deinitialized;
int Chart_Scale,Bar_Width;
int init() {
Deinitialized = false;
//Determine the current chart scale (chart scale number should be 0-5)
Chart_Scale = ChartScaleGet();
//Set bar widths
if(Chart_Scale == 0) {Bar_Width = 1;}
else {if(Chart_Scale == 1) {Bar_Width = 2;}
else {if(Chart_Scale == 2) {Bar_Width = 2;}
else {if(Chart_Scale == 3) {Bar_Width = 3;}
else {if(Chart_Scale == 4) {Bar_Width = 6;}
else {Bar_Width = 13;} }}}}
SetIndexStyle(0, DRAW_HISTOGRAM,0,Bar_Width);
return(0);
}
//+-------------------------------------------------------------------------------------------+
//| Subroutine: Set up to get the chart scale number |
//+-------------------------------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
Chart_Scale = ChartScaleGet();
init();
}
//+-------------------------------------------------------------------------------------------+
//| Subroutine: Get the chart scale number |
//+-------------------------------------------------------------------------------------------+
int ChartScaleGet()
{
long result = -1;
ChartGetInteger(0,CHART_SCALE,0,result);
return((int)result);
}
//+-------------------------------------------------------------------------------------------+
//|Custom indicator end |
//+-------------------------------------------------------------------------------------------+