I am trying to use an indicator only as dashboard to draw rectangles, labels, present information...
As drawing objects is easier with X and Y coordinates, I will end up using OBJ_LABEL and OBJ_RECTANGLE_LABEL... But the indicator subwindow is based (?) on datetime and prices.
The necessary conversion ChartTimePriceToXY is giving me errors. The simple following test fails:
What is the Last Error?
You talk about the indicator sub window, but check the main chart?
You are right, sorry
int subwo=1;
You are right, sorry
int subwo=1;
I'm betting everything that you are trying to plot Times and Prices that are beyond the visual bounds of the chart. In order to get X, Y the time and price need to be in the visual window, afterall, it couldn't return X=-100, y=-50, right? So if you need time, price coordinates than you obviously should use time, price coordinates.
The problem with datetime and double is that it is difficult to program matrices of rectangles.
The weird thing I just found (after a day of suffering) is that using corners with int X and Y coordinates work well:
//+------------------------------------------------------------------+ //| DrawRectangle | //| | //+------------------------------------------------------------------+ void Rc(string label, int xPixel_1, int yPixel_1, int width, int height, color clrFill, color clrBorder, double style, int Corner=0,int subwindow=0) { ObjectDelete (0, label ) ; ChartSetInteger(0,CHART_FOREGROUND,0,false); ObjectCreate (0,label,OBJ_RECTANGLE_LABEL,subwindow,0,0); ObjectSetInteger(0,label,OBJPROP_XDISTANCE, xPixel_1 ); ObjectSetInteger(0,label,OBJPROP_YDISTANCE, yPixel_1 ); ObjectSetInteger(0,label,OBJPROP_XSIZE, width ); ObjectSetInteger(0,label,OBJPROP_YSIZE, height ); ObjectSetInteger(0,label,OBJPROP_BACK, true ); ObjectSetInteger(0, label, OBJPROP_CORNER, Corner ); ObjectSetInteger(0,label,OBJPROP_COLOR, clrBorder ); ObjectSetInteger(0,label,OBJPROP_BGCOLOR, clrFill );}
And calling this into my indicator with:
// Let me try to draw a rectangle from some corner: Rc("R1", 22,32,22,44,clrAliceBlue,clrAntiqueWhite,SS,0,1); Rc("R2", 22,122,22,44,clrAliceBlue,clrAntiqueWhite,SS,1,1);
work very well... (SS=StyleSolid redefined)
Anyway this whole idea of Indicator used as dashboard is not very elegant, I have seen EAs with large empty space below prices in the main window filled with data and labels... I do not know how to emulate this, the main window height seems so much linked with the prices themselves...
The problem with datetime and double is that it is difficult to program matrices of rectangles.
The weird thing I just found (after a day of suffering) is that using corners with int X and Y coordinates work well:
And calling this into my indicator with:
work very well... (SS=StyleSolid redefined)
I don't understand why you need to work with time and price at all if want you want to do is create a matrix of chartobjects?
#include <chartobjects/chartobjectstxtcontrols.mqh> void OnStart() { //MATRIX CChartObjectRectLabel r1, r2, r3, r4; r1.Create(0, "r1", 0, 10, 10, 100, 100); r2.Create(0, "r2", 0, 120, 10, 100, 100); r3.Create(0, "r3", 0, 10, 120, 100, 100); r4.Create(0, "r4", 0, 120,120, 100, 100); ChartRedraw(); while(!IsStopped()) Sleep(10); }
thanks nicholi for the code.
This class may be helpful for me.
Yes you are write, I was experimenting both directions, and instead of showing you my trials with ChartXYToTimePrice, I mistakenly began my question by showing ChartTimePriceToXY... So It was also an error in my question.
Maybe in the morning I had no internet connections so both ChartXYToTimePrice and ChartTimePriceToXY where giving "false"...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to use an indicator only as dashboard to draw rectangles, labels, present information...
As drawing objects is easier with X and Y coordinates, I will end up using OBJ_LABEL and OBJ_RECTANGLE_LABEL... But the indicator subwindow is based (?) on datetime and prices.
The necessary conversion ChartTimePriceToXY is giving me errors. The simple following test fails:
Any help please?