Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Wie Infos im Chart strukturierter anordnen? (http://www.expert-advisor.com/forum/showthread.php?t=3334)

pako 19.11.13 09:20

Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:

Zitat von Ca$hDigger (Beitrag 24194)
Aber dann ist nur die Schrift größer oder? Ich möchte ja ein Hintergrund für die Schriften

Code:

//+------------------------------------------------------------------+
//| script program                                                              |
//+------------------------------------------------------------------+
int start()
{
  string Header[]={"Spalte 1","Spalte 2"};
  int ColWidth[]={9,9};
  string Content[20][2];     
      for(int i=0;i<20;i++)
      {
        for(int j=0;j<2;j++)
        {
            Content[i][j]="Spalte "+(j+1)+", Zeile "+(i+1);
        }
      }
  fObjLableTable("Table_a",Header,ColWidth,Content,5,10,10,12,Silver,Navy,true,Gainsboro,Black);
  fObjLableTable("Table_b",Header,ColWidth,Content,45,110,10,10,Red,Yellow,true,Lime,Blue); 
  fObjLableTable("Table_c",Header,ColWidth,Content,125,180,10,8,Black,White,true,White,Black);   
  fObjLableTable("Table_d",Header,ColWidth,Content,250,230,10,6,Aqua,Navy,true,DodgerBlue,Yellow); 
  fObjLableTable("Table_e",Header,ColWidth,Content,80,270,10,4,Yellow,Red,true,Khaki,Black); 
  fObjLableTable("Table_f",Header,ColWidth,Content,30,295,10,2,Blue,Aqua,true,Red,Yellow);   
}
void fObjLableTable(
                        string aName,
                        string aHeader[],                           
                        int aColWidth[],                           
                        string aContent[][],                       
                        int aX                    =  5,           
                        int aY                    =  10,           
                        int aRows                  =  30,         
                        int tTableSize            =  4,           
                        color aHeaderBackColor    =  Silver,       
                        color aHeaderTextColor    =  Navy,         
                        bool aHeaderBold          =  true,         
                        color aContentBackColor    =  Gainsboro,   
                        color aContentTextColor    =  Black       
                        )
                        {
  int tFontSize;
  int tBoxFontSize;
  int tBoxWidth;
  int tTextXMargin;
  int tTextYMargin;
  int tHeaderCorrector;
      switch(tTableSize){
        case 1:  tFontSize=5;  tBoxFontSize=10;  tBoxWidth=8;  tTextXMargin=5;  tTextYMargin=4;  tHeaderCorrector=-1; break;
        case 2:  tFontSize=6;  tBoxFontSize=14;  tBoxWidth=10;  tTextXMargin=6;  tTextYMargin=5;  tHeaderCorrector=-1; break;
        case 3:  tFontSize=7;  tBoxFontSize=16;  tBoxWidth=12;  tTextXMargin=6;  tTextYMargin=6;  tHeaderCorrector=-1; break;
        case 4:  tFontSize=8;  tBoxFontSize=18;  tBoxWidth=14;  tTextXMargin=6;  tTextYMargin=6;  tHeaderCorrector=-1; break;     
        case 5:  tFontSize=10;  tBoxFontSize=22;  tBoxWidth=17;  tTextXMargin=8;  tTextYMargin=8;  tHeaderCorrector=-1; break;
        case 6:  tFontSize=12;  tBoxFontSize=26;  tBoxWidth=20;  tTextXMargin=9;  tTextYMargin=9;  tHeaderCorrector=-2; break;     
        case 7:  tFontSize=14;  tBoxFontSize=32;  tBoxWidth=24;  tTextXMargin=12;  tTextYMargin=12;  tHeaderCorrector=-2; break;       
        case 8:  tFontSize=16;  tBoxFontSize=36;  tBoxWidth=28;  tTextXMargin=15;  tTextYMargin=15;  tHeaderCorrector=-3; break; 
        case 9:  tFontSize=18;  tBoxFontSize=42;  tBoxWidth=32;  tTextXMargin=18;  tTextYMargin=18;  tHeaderCorrector=-4; break;             
        case 10: tFontSize=20;  tBoxFontSize=46;  tBoxWidth=35;  tTextXMargin=18;  tTextYMargin=18;  tHeaderCorrector=-4; break; 
        case 11: tFontSize=22;  tBoxFontSize=48;  tBoxWidth=37;  tTextXMargin=18;  tTextYMargin=18;  tHeaderCorrector=-4; break;   
        case 12: tFontSize=24;  tBoxFontSize=52;  tBoxWidth=40;  tTextXMargin=21;  tTextYMargin=21;  tHeaderCorrector=-6; break;               
      }
  int tCollXPOsAdd_1=0;
  int tCollXPOsAdd_2=0; 
  int tCollXPOsAdd_3=0;     
  string tHeaderFont="Arial";
  int tHeaderYAdd=0;
      if(aHeaderBold){
        tHeaderFont=tHeaderFont+" Black";
        tHeaderYAdd=tHeaderCorrector;
      }
  int tBoxHeight=tBoxWidth+1;       
  int tHeaderCounter=0;
  int tRowCounter=0;
  int tWindowNumber=0;
      for(int tk=0;tk<ArraySize(aContent)/ArraySize(aHeader);tk++)
{
            if(tRowCounter==0)
{
              tCollXPOsAdd_1=0;
                  for(int ti=0;ti<ArraySize(aHeader);ti++)
                  {
                        for(int tj=0;tj<aColWidth[ti];tj++)
                        {
                          string tName=aName+"_hb_"+tHeaderCounter+"_"+ti+"_"+tj;
                          fObjLabel(tName,aX+tCollXPOsAdd_2+tCollXPOsAdd_1+tj*tBoxWidth,aY,"n",0,aHeaderBackColor,tBoxFontSize,0,"WingDings",false);
                        }     
                    fObjLabel(aName+"_ht_"+tHeaderCounter+"_"+ti,aX+tCollXPOsAdd_2+tCollXPOsAdd_1+tTextXMargin,aY+tTextYMargin+tHeaderYAdd,aHeader[ti],0,aHeaderTextColor,tFontSize,0,tHeaderFont,false);
                    tCollXPOsAdd_1+=aColWidth[ti]*tBoxWidth+1;
                  }
              tCollXPOsAdd_3=tCollXPOsAdd_2;   
              tCollXPOsAdd_2+=tCollXPOsAdd_1+3;
              tHeaderCounter++;
            }
        tCollXPOsAdd_1=0;
            for(ti=0;ti<ArraySize(aHeader);ti++)
            {
                  for(tj=0;tj<aColWidth[ti];tj++)
                  {
                    fObjLabel(aName+"_cb_"+tHeaderCounter+"_"+tRowCounter+"_"+ti+"_"+tj,aX+tCollXPOsAdd_3+tCollXPOsAdd_1+tj*tBoxWidth,aY+tRowCounter*tBoxHeight+tBoxHeight,"n",0,aContentBackColor,tBoxFontSize,0,"WingDings",false);
                  }     
              fObjLabel(aName+"_ct_"+tHeaderCounter+"_"+tRowCounter+"_"+ti,aX+tCollXPOsAdd_3+tCollXPOsAdd_1+tTextXMargin,aY+tTextYMargin+tRowCounter*tBoxHeight+tBoxHeight,aContent[tk][ti],0,aContentTextColor,tFontSize,0,"Arial",false);
              tCollXPOsAdd_1+=aColWidth[ti]*tBoxWidth+1;
            } 
        tRowCounter++;
            if(tRowCounter>=aRows)
            {
              tRowCounter=0;
            }
      }
  WindowRedraw();     
}

void fObjLabel(
  string aObjectName,             
  int aX,                         
  int aY,                         
  string aText,                   
  int aCorner      =  0,       
                                 
  color aColor      =  Red,     
  int aFontSize    =  8,         
  int aWindowNumber =  0,       
  string aFont      =  "Arial",   
  bool aBack        =  false     
  )
  { 
      if(ObjectFind(aObjectName)!=aWindowNumber)
      {
        ObjectCreate(aObjectName,OBJ_LABEL,aWindowNumber,0,0);
      }     
  ObjectSet(aObjectName,OBJPROP_XDISTANCE,aX);
  ObjectSet(aObjectName,OBJPROP_YDISTANCE,aY); 
  ObjectSetText(aObjectName,aText,aFontSize,aFont,aColor);
  ObjectSet(aObjectName,OBJPROP_BACK,aBack);
  ObjectSet(aObjectName,OBJPROP_CORNER,aCorner); 
}


pako 19.11.13 10:27

Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:

Zitat von Ca$hDigger (Beitrag 24194)
Aber dann ist nur die Schrift größer oder? Ich möchte ja ein Hintergrund für die Schriften

:rolleyes:

Ca$hDigger 19.11.13 20:08

Danke prima!

Ca$hDigger 30.11.13 18:30

Hallo,

noch eine Frage zum Thema: Bis zur 8. Nachkommastelle werden bei double-Werten die Nullen im Chart angehängt was für das Chartbild unschön ist.
Also z.B. der Wert 1.2345 wird als 1.23450000 angezeigt. Gibts da ein kleinen Trick die überflüssigen Nullen los zu werden?

Code:

string text1 ="High:"+Bid;

string name1 = "InfoBar1";

int WhichCorner=2;//0,1,2 or 3

string sObjName="InfoBar1";
ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0);
ObjectSetText(sObjName,text1, 9, "Arial", YellowGreen);
ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner);
ObjectSet(sObjName, OBJPROP_XDISTANCE, 200);//left to right
ObjectSet(sObjName, OBJPROP_YDISTANCE, 60);//top to bottom


traderdoc 30.11.13 18:47

Code:

string text1 ="High:"+ DoubleToStr(Bid, Digits);

string name1 = "InfoBar1";

int WhichCorner=2;//0,1,2 or 3

string sObjName="InfoBar1";
ObjectCreate(sObjName, OBJ_LABEL, 0, 0, 0);
ObjectSetText(sObjName,text1, 9, "Arial", YellowGreen);
ObjectSet(sObjName, OBJPROP_CORNER, WhichCorner);
ObjectSet(sObjName, OBJPROP_XDISTANCE, 200);//left to right
ObjectSet(sObjName, OBJPROP_YDISTANCE, 60);//top to bottom


Ca$hDigger 30.11.13 18:58

Danke das ist schonmal eine gute Lösung für Werte die Kurswerte betreffen.
Da sich nicht alle double-Werte auf Kurswerte beziehen gibt es auch eine Möglichkeit wo generell die überflüssigen Nachkomma-Nullen eliminiert werden?

traderdoc 30.11.13 23:16

DoubleToStr(Bid, Digits);

Ob da nun Bid, Ask, Banane oder Meer*******chen als Variable steht, ist doch völlig Wurscht!

traderdoc

Ca$hDigger 01.12.13 00:10

Naja aber die Variablen würden in Abhängigkeit des Währungspaares gekürzt und nicht nach überflüssigen Nullen. Im EURJPY (Digits=3) würde jede Variable mit mehr als 3 Nachkommastellen nicht vollständig angezeigt werden. Und im EURUSD (Digits=5) würde eine Variable mit nur einer Nachkommastelle noch 4 weitere Nullen angehängt haben.

Statt Digits kann man auch einfach manuell die Nachkommastellen eingeben, man hat es meißtens mit Variablen zu tun die bei Veränderungen die selbe Anzahl von Nachkommastellen behält von daher ist das schon mal gut damit kann man gut arbeiten.:
DoubleToStr(double_Variable, Anzahl_Nachkommastellen);


Alle Zeitangaben in WEZ +2. Es ist jetzt 05:24 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum