Jump to content
Tom Next - Daytrading Community

Problem mit OBJ_RECTANGLE


Bernd

Recommended Posts

Wie bekomme ich ein OBJ_RECTANGLE immer in die Linke obere Ecke.

So wirklich einfach ist das nicht, da du bei einem Rechteck keine X/Y-Koordinaten angeben kannst sondern nur Zeit/Kurs.

 

Du müßtest also dazu bei jedem sich neu bildenden Bar das Rechteck mit ObjectMove() um eine Zeiteinheit verschieben.

Das Problem dabei ist aber immer noch, daß sich die Y-Auflösung auch ändert. Das Rechteck "klebt " ja quasi an einem Kurs und hinzu kommt, wenn sich die

Vola erhöht, dann wird dein Rechteck auch noch kleiner.

 

Wenn ich mir's so recht überlege, würde das wohl ziemlich aufwändig werden, zumindest fällt mir nichts vernünftiges ein. :birdie:

Link to comment
Share on other sites

Wogo hat die Problematik schon skizziert. "Oben Links" ändert sich laufend, schon wenn du mit der Maus im Chart rumscrollst.

Ich hab einen Indikator der vermutlich genau das macht was du willst:

 

//+------------------------------------------------------------------+
//|                                           commentsBackground.mq4 |
//|                                                               ps |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "ps"
#property link      ""

#property indicator_chart_window
extern double width=32;
extern double heigth=65;
extern color col=Brown;

string title="commentsBG";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
 {
//---- indicators
  datetime obenLinksDatum=iTime(Symbol(),0,WindowFirstVisibleBar());
  double obenLinksPreis=WindowPriceMax(0);
  datetime untenRechtsDatum=iTime(Symbol(),0,WindowFirstVisibleBar()-WindowBarsPerChart()*(width/100));
  double untenRechtsPreis=WindowPriceMax(0)-(WindowPriceMax(0)-WindowPriceMin(0))*(heigth/100);
  
  ObjectCreate(title,OBJ_RECTANGLE,0,obenLinksDatum,obenLinksPreis,untenRechtsDatum,untenRechtsPreis);
  ObjectSet(title,OBJPROP_COLOR,col);
//----
  return(0);
 }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
 {
//----
  
//----
  return(0);
 }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
 {
  int    counted_bars=IndicatorCounted();
//----
  datetime obenLinksDatum=iTime(Symbol(),0,WindowFirstVisibleBar());
  double obenLinksPreis=WindowPriceMax(0);
  datetime untenRechtsDatum=iTime(Symbol(),0,WindowFirstVisibleBar()-WindowBarsPerChart()*(width/100));
  double untenRechtsPreis=WindowPriceMax(0)-(WindowPriceMax(0)-WindowPriceMin(0))*(heigth/100);
  
  ObjectSet(title,OBJPROP_PRICE1,obenLinksPreis);
  ObjectSet(title,OBJPROP_PRICE2,untenRechtsPreis);
  ObjectSet(title,OBJPROP_TIME1,obenLinksDatum);
  ObjectSet(title,OBJPROP_TIME2,untenRechtsDatum);
  
//----
  return(0);
 }
//+------------------------------------------------------------------+

 

Supportfrei!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...