问题
I hope to draw a graph like this (with blue border surrounding two candles)
with the following code,
string label_name="Rectangle";
double maxHigh=MathMax(iHigh(_Symbol,0,1),iHigh(_Symbol,0,2));
double minLow=MathMin(iLow(_Symbol,0,1),iLow(_Symbol,0,2));
ObjectCreate(0,label_name, OBJ_RECTANGLE_LABEL, 0, Time[2],maxHigh, Time[1],minLow);
ObjectSetInteger(0,label_name,OBJPROP_XSIZE,100);
ObjectSetInteger(0,label_name,OBJPROP_COLOR,clrBlue);
ObjectSetInteger(0,label_name,OBJPROP_BACK,false);
ObjectSetInteger(0,label_name,OBJPROP_WIDTH,3);
i get the following (not surrounding the candle), how should I make it work?
回答1:
do you need OBJ_RECTANGLE_LABEL
? it can be useful if you want to have some kind of background, and when you move your chart right or left it remains in the selected corner. It's position depends on x and y coordinates of the chart, width and heigth. If you use OBJ_RECTANGLE
- it would be drawn based on price and time coordinates, no need in editing OBJPROP_XSIZE in such case, just ObjectSetDouble(0,name,OBJPROP_PRICE1,fmax(high[1],high[2]);
ObjectSetDouble(0,name,OBJPROP_PRICE2,fmin(low[1],low[2]);
来源:https://stackoverflow.com/questions/42674261/blue-border-surrounding-two-candles