Download MetaTrader 5

Subwindow indicator problem

To add comments, please log in or register
PieroNetto
296
PieroNetto  

Hi everyone!

So in the moment i'm trying to build a indicator in the subwindow using   ObjectSetCreate() ObjectSetText() ObjectSet() for text and SetIndexBuffer() SetIndexStyle() SetIndexLabel()

for the indicator. 

Problem 1) The line up between a text line and the indicator line change by resizing the subwindow. Any hint to not do that? Thanks.


 i created a OBJ_RECTANGLE_LABEL background behind the text so the indicator would not interfere with the text

Problem 2) The OBJ_RECTANGLE_LABEL shows borders i like to have invisible and the only way to do this is with ObjectSetInteger(0,"Backround",OBJPROP_BORDER_TYPE,clrRed);

clrRed???????????  realy????????   clrBlack  does not work.

Thanks for any help to make that work.

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
extern int              Frankfurt_Open  =  8;
extern int              Frankfurt_Close = 16;

double Frankfurt[];
int init()
{     
        SetIndexBuffer(0,Frankfurt);
        SetIndexStyle(0,0,EMPTY,8,clrBlue);
        SetIndexLabel(0,"Frankfurt");
return(0);
}
int start()
{
        int iBarsToCalc = Bars - IndicatorCounted();
        if (iBarsToCalc < Bars) iBarsToCalc++;
        for (int i=iBarsToCalc-1;i>=0;i--) 
        {
                if (isMarketOpen(Frankfurt_Open, Frankfurt_Close, Time[i]))
                        Frankfurt[i] = 67; // 67 is the position from 0 to 100 on the subwindow
                else
                        Frankfurt[i] = EMPTY_VALUE;
   }

Text();
Backround();
return(0);
}

bool isMarketOpen(int iOpenHour, int iCloseHour, datetime timestamp)
   {

        int iBarHour = TimeHour(timestamp);
        
        if (iOpenHour < iCloseHour && (iBarHour >= iOpenHour && iBarHour < iCloseHour))
                return(true);
        if (iOpenHour > iCloseHour && (iBarHour >= iOpenHour || iBarHour < iCloseHour))
                return(true);
                
        return(false);
   }  
void Backround()
   {
//---
   ObjectCreate    (0,"Backround",OBJ_RECTANGLE_LABEL,1,0,0);
   ObjectSetInteger(0,"Backround",OBJPROP_BGCOLOR,clrBlack);
   ObjectSetInteger(0,"Backround",OBJPROP_BORDER_TYPE,clrRed); //problem here is using clrRed hide's the border,should not be that way, should be clrBlack or 0
   ObjectSet       ("Backround",OBJPROP_XDISTANCE,0);
   ObjectSet       ("Backround",OBJPROP_YDISTANCE,0);
   ObjectSet       ("Backround",OBJPROP_XSIZE,115);
   ObjectSet       ("Backround",OBJPROP_YSIZE,1000);
   }
void Text()
   {
   ObjectCreate    ("text",OBJ_LABEL,1,0,0);
   ObjectSetText   ("text","Line Up Here   ",14,"Tahoma",clrRed);
   ObjectSet       ("text", OBJPROP_CORNER, 0);
   ObjectSet       ("text",OBJPROP_XDISTANCE,3);
   ObjectSet       ("text",OBJPROP_YDISTANCE,50);
  }
  
  

I'm already excited what's coming my way thanks to you all.

Naguisa Unada
121
Naguisa Unada  
PieroNetto :

Problem 1) The line up between a text line and the indicator line change by resizing the subwindow. Any hint to not do that? Thanks.

It happens because of the use of Time and Price for lines and X and Y for Text to specify the position. I think that you should use the same method for both.

For example,

void Text()
  {
   ObjectDelete("text");
   //ObjectCreate("text",OBJ_LABEL,1,0,0);
   ObjectCreate("text",OBJ_TEXT,1,Time[WindowFirstVisibleBar()],67);
   ObjectSetText("text","Line Up Here   ",14,"Tahoma",clrRed);
   //ObjectSet("text",OBJPROP_CORNER,0);
   //ObjectSet("text",OBJPROP_XDISTANCE,3);
   //ObjectSet("text",OBJPROP_YDISTANCE,50);
  }
PieroNetto
296
PieroNetto  
Naguisa Unada:

It happens because of the use of Time and Price for lines and X and Y for Text to specify the position. I think that you should use the same method for both.

For example,


Thanks a lot for your help. It seems to be the right idea to go with, but you see is still not lining up. It seems to move in the same distance by resizing the subwindow.

If i change the settings so they're different from each other, not equal "67" and then resizing the window, the same problem like before, the are moving away from each other.

The other thing is, half the text is not visible.

Here is another thing i just found out, with the cursor over the indicator shows always 67.00000 by resizing the subwindow and by the text it always changes, is not standing on the 67.00000 or never does from the beginning.




I appreciate your help, Thanks very much regards Piero

To add comments, please log in or register