Trying to make a whiteboard. What I'm doing wrong.

Back to topics list To post a new topic, please log in or register
avatar
8
manuel_campelo 2015.05.13 10:01
 

  I'm trying to write an EA that finds signals, display them on screen and user decides whether or not to trade them (besides, it handles all open positions and do some stuff). When I have done almost everything, Ive encountered two problems and I don't find anywhere a solution.

   First of all, I send you two snapshots of the screen. First one is what I see when debugging (running the Ea from Metaeditor) and the 2nd one when running from Terminal.



   As you can see, When running from terminal, bars/lines don't dissapear. I've tried with all properties of the chart and didn't work, tried to put a white rectangle label on the backgroung filling all the chart and also didn't do the trick. Someone knows how to solve this?.

 My second problems id the following: I'd like to enable the user to change signals or opentrades settings (for instance, if a signal calculates lot as a fixed size, let me change it before opening or change Sl or TP on an open order). When clicking on a bitmaplabel objects there is no problem (chartevent recognizes that I've clicked on them) but things change when I try to click on a label. It never recognizes it, it says that I clicked on the rectangle label that is on the background. I tried to change zorder & back properties but i didnt succeed. What I'm doing wrong?

 

  Thanks everyone. Coding wouldn't be possible without the ppriceless help this forum gives.

 


avatar
Moderator
3406
GumRai 2015.05.13 10:49 #
 

If you use a rectangle label, make sure to set it as foreground

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,false);

 and obviously create it before any other objects

 

avatar
8
manuel_campelo 2015.05.14 12:18 #
 

I did, here is the code that creates the rectangle label.

void NewRectangleLabel(long chart,string name, int x,int y,int xsize, int ysize,int corner=CORNER_LEFT_UPPER,
         int bordertype=BORDER_FLAT,uint bordercol=clrDarkGray, uint col=clrLightGray, bool del_first=false) {

   ObjectCreate(chart,name,OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(ThisChart,name,OBJPROP_BORDER_TYPE,bordertype);
   ObjectSetInteger(chart,name,OBJPROP_BORDER_COLOR,bordercol);
   ObjectSetInteger(chart,name,OBJPROP_BGCOLOR,col);
   ObjectSetInteger(chart,name,OBJPROP_BACK,false);   ObjectSetInteger(chart,name,OBJPROP_HIDDEN,true);
   ObjectSetInteger(chart,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(chart,name,OBJPROP_CORNER,corner);
   ObjectSetInteger(chart,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart,name,OBJPROP_XSIZE,xsize);
   ObjectSetInteger(chart,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(chart,name,OBJPROP_YSIZE,ysize);
   ObjectSetInteger(chart,name,OBJPROP_ZORDER,0);

}

And also is created before anything.

void DrawGeneralInfo(string chunk1,string path, int xterm, int yterm) {
   //General Frame
   NewRectangleLabel(ThisChart,"Background",0,0,ChartGetInteger(ThisChart,CHART_WIDTH_IN_PIXELS),ChartGetInteger(ThisChart,CHART_HEIGHT_IN_PIXELS),CORNER_LEFT_UPPER,BORDER_FLAT,clrWhite,clrWhite);
   ObjectSet("Background",OBJPROP_WIDTH,0);
   NewBitmapLabel(ThisChart,"Clock",path+"Clock.bmp",size*35-25,0,CORNER_LEFT_UPPER);
   NewLabel(ThisChart,"FirstLine","@"+ExpertName+". manuel_campelo@yahoo.com",size*7,0,CORNER_RIGHT_UPPER,clrBlack,size-2);
   NewLabel(ThisChart,"Account",IntegerToString(AccountNumber())+" ("+AccountCurrency()+") . ("+
      TimeToStr(InitTime,TIME_DATE|TIME_SECONDS)+").",5,5,CORNER_LEFT_UPPER,clrBlack,size-2);
   NewRectangleLabel(ThisChart,"Rect5",xterm+122,yterm-3,131,90,CORNER_RIGHT_UPPER,BORDER_RAISED,clrBlack,clrWhite);
   //FontSize label & Buttons.
   if (size==MaxSize) {
      NewBitmapLabel(ThisChart,"Bigger",path+"FontUpOff.bmp",xterm+30,yterm+30,CORNER_RIGHT_UPPER);
   } else {
      NewBitmapLabel(ThisChart,"Bigger",path+"FontUp.bmp",xterm+30,yterm+30,CORNER_RIGHT_UPPER);
   }
   if (size==MinSize) {
      NewBitmapLabel(ThisChart,"Smaller",path+"FontDownOff.bmp",xterm,yterm+30,CORNER_RIGHT_UPPER);
   } else {
      NewBitmapLabel(ThisChart,"Smaller",path+"FontDown.bmp",xterm,yterm+30,CORNER_RIGHT_UPPER);
   }
etc......

When refreshing screen I call the functions in order:

         DrawGeneralInfo(chunk1,path,xterm,yterm); //Draws general info of the account + some buttons and state images
         DrawSignals(path,xsig,ysig);
         DrawTrades(path,xtrd,ytrd);
         DrawMessages(path,xmes,ymes);
         DrawTable();  //Draw a table & Fill content.
avatar
145
aakcaagac 2015.05.14 22:20 #
 
Within Metatrader: Menu -> Charts -> unselect "Foreground chart". This actually isn't enabled by default.
avatar
8
manuel_campelo 2015.05.15 09:19 #
 

Thanks, This solves my first issue. And searching I found that this can be done by code:    ChartSetInteger(ThisChart,CHART_FOREGROUND,false);

Does anyone know how to solve second one? Thanks in advance.


avatar
145
aakcaagac 2015.05.15 12:55 #
 

Try this here (CHART_FOREGROUND). I haven't tested this but it seems to be the thing. Set to false should do the trick.

Update: Just saw that you altered your previous comment. Nice your found it.

Back to topics list  

To add comments, please log in or register