I still couldn't find a solution to this. Is it possible to adjust the Cart in such a way that the line width will over shadow 10 pips (the example I used above).
I could only find these chart operations however I need more info on them, anybody have some ideas?
CHART_SCALE |
Scale ( what is the scale diffrence between 0 and 1?? ) |
int from 0 to 5 |
CHART_SCALEFIX |
Fixed scale mode ( If I set this to true, where do I spesifiy the scale?) |
bool |
CHART_SCALEFIX_11 |
Scale 1:1 mode |
bool |
CHART_SCALE_PT_PER_BAR |
Scale to be specified in points per bar ( if this is true, where do I spesify the points per bar ) |
bool |
Stuff I tried:
Set the chart to 1to1 and draw the line with a width of 10, hoping that when the chart is on 1to1, 1 pixel will be one pip. this didn't work.
- www.mql5.com
It seems I've been looking at the wrong place to get my information. I created a horizontal line using ObjectCreate.
When getting the properties below using ObjectGetInteget() they return 0. I'm looking for a property that would return the width of my horizontal line in points and NOT pixels.
OBJPROP_XSIZE |
The size of the Chart object along the X axis (width in pixels) |
int |
OBJPROP_YSIZE |
The size of the Chart object along the Y axis (height in pixels) |
int |
OBJPROP_XOFFSET |
The X coordinate of the upper left corner of the rectangular visible area in the graphical objects "Bitmap Label" and "Bitmap" (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image. |
int |
OBJPROP_YOFFSET |
The Y coordinate of the upper left corner of the rectangular visible area in the graphical objects "Bitmap Label" and "Bitmap" (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image. |
int |
I was expecting OBJPROP_YSIZE to return what I needed but like it stipulates ...pixels
anyidea?
What do I want to do?
I want to write a support and resistance indicator that draws horizontal lines in the back ground and change the color when getting to support or resistance lines.
I have attached simple script to prove my point that these properties dont return anything.
please help! I need points not pixels...
Hi toolmaker,
Have you consider using a rectangle instead of an horizontal line. If you set the time parameters to the oldest bar and some time after the most recent bar you get what you want. Price parameters can be set to meet your needs in points and will maintain when you rescale your chart. Try the code below in a script.
/////////////////////
datetime time[];
ArraySetAsSeries(time,true);
bool copied_time=CopyTime(NULL,0,0,Bars(_Symbol,_Period),time);
int bars = ArraySize(time);
MqlRates rates[];
ArraySetAsSeries(rates,true);
bool copied_rates = CopyRates(_Symbol,_Period,0,100,rates);
datetime time1 = time[0]+(60*60*24*30); //bottom right corner
datetime time2 = time[bars-1];//top left corner
double price1 = rates[0].close;//bottom right corner
double price2 = rates[0].close - (100*_Point);//top left corner
bool created=ObjectCreate(0,"Rectangle",OBJ_RECTANGLE,0,time1,price1,time2,price2);
if(created)
{
ObjectSetInteger (0, "Rectangle", OBJPROP_FILL, true);
ObjectSetInteger (0, "Rectangle", OBJPROP_BACK, true);
ObjectSetInteger (0, "Rectangle", OBJPROP_COLOR, color(Green));
}
//////////////////
to change the color is easy once the object is created
////////
ObjectSetInteger(0,"Rectangle",OBJPROP_COLOR,color(Red));
///////
Hope it helps, regards
- www.mql5.com
Hi toolmaker,
Have you consider using a rectangle instead of an horizontal line. If you set the time parameters to the oldest bar and some time after the most recent bar you get what you want. Price parameters can be set to meet your needs in points and will maintain when you rescale your chart. Try the code below in a script.
/////////////////////
datetime time[];
ArraySetAsSeries(time,true);
bool copied_time=CopyTime(NULL,0,0,Bars(_Symbol,_Period),time);
int bars = ArraySize(time);
MqlRates rates[];
ArraySetAsSeries(rates,true);
bool copied_rates = CopyRates(_Symbol,_Period,0,100,rates);
datetime time1 = time[0]+(60*60*24*30); //bottom right corner
datetime time2 = time[bars-1];//top left corner
double price1 = rates[0].close;//bottom right corner
double price2 = rates[0].close - (100*_Point);//top left corner
bool created=ObjectCreate(0,"Rectangle",OBJ_RECTANGLE,0,time1,price1,time2,price2);
if(created)
{
ObjectSetInteger (0, "Rectangle", OBJPROP_FILL, true);
ObjectSetInteger (0, "Rectangle", OBJPROP_BACK, true);
ObjectSetInteger (0, "Rectangle", OBJPROP_COLOR, color(Green));
}
//////////////////
to change the color is easy once the object is created
////////
ObjectSetInteger(0,"Rectangle",OBJPROP_COLOR,color(Red));
///////
Hope it helps, regards
Thanks for this simple answer :) this is exactly what I need.
HI,
Just to help make thing easier because I couldn't find my solution in the documentation. I draw my rectangle but I had to modify the size as new bars appeared. I couldn't find this anywhere except on one articable.
if you need to modify the coordinates use the code below:
ObjectSetInteger(ChartID(),LineName,OBJPROP_TIME,0,StartTimeFrame);
ObjectSetDouble(ChartID(),LineName,OBJPROP_PRICE,0,StartPoint);
ObjectSetInteger(ChartID(),LineName,OBJPROP_TIME,1,rates.time);
ObjectSetDouble(ChartID(),LineName,OBJPROP_PRICE,1,EndPoint);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I need to draw a horizontal line that spreads over a certain amount of pips. I noted the documentation on OBJPROP_WIDTH doesn't specifies what the width actualy represents? Does it represent pixels or pips?
I did a test and it is definitaly not pips because of the scaling diffrence of each window.
How can I calculate a width to be exactly 10 pips for example?