Proportional Chart Objects

 

Does anyone know if it is possible to create objects on the chart that are proportional to the chart screen size....? ie. If I have a rectangle eg. H=20 W=100 when my chart is "Full Screen"... those rectangle stats become H= 10 W=50 when the chart size is minimized to half the full screen...

If "yes" could you please point me in the right direction here... thanx 

 
Mike.T: If I have a rectangle eg. H=20 W=100
  1. A rectangle is created by two price/time coordinates. Your statement makes no sense.
  2. Do you mean a rectangle label? Do you get the chart size? See the example in ChartGetInteger - Chart Operations - MQL4 Reference
  3. If yes it's not going to change it's size, you must do that. Post your code.
 
WHRoeder:
Mike.T: If I have a rectangle eg. H=20 W=100
  1. A rectangle is created by two price/time coordinates. Your statement makes no sense.
  2. Do you mean a rectangle label? Do you get the chart size? See the example in ChartGetInteger - Chart Operations - MQL4 Reference
  3. If yes it's not going to change it's size, you must do that. Post your code.

Hi Roeder

Thanx... that's what I was looking for...  So I can calculate the size of my chart (using - CHART_HEIGHT_IN_PIXELS)and then multiply my Static Object co-ordinates/values by that proportional fraction... if "full screen" = 100%...

Ok... I'll try that... thanx 

PS: I don't have code to paste yet... I was wondering if it was possible... 

 
Mike.T:

Hi Roeder

Thanx... that's what I was looking for...  So I can calculate the size of my chart (using - CHART_HEIGHT_IN_PIXELS)and then multiply my Static Object co-ordinates/values by that proportional fraction... if "full screen" = 100%...

Ok... I'll try that... thanx 

PS: I don't have code to paste yet... I was wondering if it was possible... 

Hi Roeder... thanx... that really put me on the right track...

What I've done is simply create a function that multiplies my static objects by a coefficient... I haven't tested it yet but in theory it should work... this is my function.. 

//+-------------------------------------+
//| Proportional Objects Function       |
//+-------------------------------------+

void proportional_Function()
   {
double FullScreenHeight = 356;  // Obviously you could set up an extern variable input for this
double FullScreenWidth = 1317;  //Ditto

   height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   
   Height_Coeficient = (height/FullScreenHeight)*100;
   Width_Coeficient = (width/FullScreenWidth)*100;
   }

 So thanx... 

I obviously then just multiply my Objects (Height/Width) with the Height/Width-Coeficient.... should work... thanx 

 
Mike.T:

Hi Roeder... thanx... that really put me on the right track...

What I've done is simply create a function that multiplies my static objects by a coefficient... I haven't tested it yet but in theory it should work... this is my function.. 

 So thanx... 

I obviously then just multiply my Objects (Height/Width) with the Height/Width-Coeficient.... should work... thanx 

Ok... that works like a charm.... 
 
Mike.T:
Ok... that works like a charm.... As a matter of interest... it slows things up a bit... but if you have a Profile with 6 charts and you have static Objects or ObjectLables.... then this is a very neat trick to getting everything into perspective... I havn't worked out how to get the TestLables to fit... but it's now just a matter of playing around...
Reason: