Question about OBJ_TRIANGLE
can this type of object be moved around and positioned on the chart using 3 coordinates with
ObjectSet(obj_name,
OBJPROP_XDISTANCE,x_coor);
ObjectSet(obj_name, OBJPROP_XDISTANCE,x_coor);
No.
Thank you very much, RaptorUk, i appreciate your response..
But does any one know if this option will be accessible in MQL5?
I really keep on having a lot of interesting ideas for graphic representation of a behavior of my EA, but i need it to be manifested on top of everything and, sadly, only text and arrow are available on that level.
I have a feeling that just language addition is not much of a problem - in fact, it feels to me like something that many, not just me would like to have being available.
thanks
In fact there is a way to keep all object relative to your chart's screen. It requires a script or EA that will constantly readjust object's price-time coordinates in accordance with the screen's coordinates. We have already created such projects.
In fact there is a way to keep all object relative to your chart's screen. It requires a script or EA that will constantly readjust object's price-time coordinates in accordance with the screen's coordinates. We have already created such projects.
I know - this was the first thing I though about when I realized that it was not possible... in my mind I can see very cleardy how to write such code - it's just that it keeps on getting SO frustrating when a "simple" idea eventually takes days to manifest...
So, yes - it would be GREATLY appreciated, I believe not jut by me, if you post a code for that. in turn - i will promise to pose the final code for my "graphic signal meter" that i want to make based on those triangles ;) is this a deal?
Here it is. This is a script that position object in relation to the chart's screen with XY coordinates.
//+------------------------------------------------------------------+ //| Object_Coordinates.mq4 | //| Copyright © 2012, RoboFX.org | //| http://www.robofx.org | //+------------------------------------------------------------------+ #property copyright "Copyright © 2012, RoboFX.org" #property link "http://www.robofx.org" #import "user32.dll" bool GetWindowRect(int hWnd, int& lpRect[]); #import //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- string name, substr; int X, Y, Bar, end, comma; double Price; //+------------------------------------------------------------------------------+ // *** Here are some examples of Objects you can use *** | // Object name should be in the following format OBJNAME_XY:X1,Y1;X2,Y2;X3,Y3; | | ObjectCreate("OBJ1_XY:50,100;60,300;300,200;",OBJ_TRIANGLE,0,0,0);// | ObjectCreate("OBJ2_XY:200,50;600,400;",OBJ_TREND,0,0,0);// | ObjectCreate("OBJ3_XY:500,250;",OBJ_ARROW,0,0,0);// | //+------------------------------------------------------------------------------+ while(!IsStopped()) { for(int i=0; i<ObjectsTotal(); i++) { name=ObjectName(i); if(StringFind(name,"XY:")>-1) { substr = StringSubstr(name,StringFind(name,":")+1); for(int p=0; p<3; p++) { end = StringFind(substr,";"); comma = StringFind(substr,","); X = StrToInteger(StringSubstr(substr,0,comma)); Y = StrToInteger(StringSubstr(substr,comma+1,end-comma-1)); substr = StringSubstr(substr,end+1); if(XY2PriceTime(X, Y, Price, Bar)) { ObjectSet(name,p*2+1,Price); ObjectSet(name,p*2,i_Time(NULL,0,Bar)); } } } } Sleep(10); } //---- return(0); } //+------------------------------------------------------------------+ bool XY2PriceTime(int X, int Y, double& Price, int& Bar) { int SizeX, SizeY; int lpRect[4]; if(GetWindowRect(WindowHandle(Symbol(),Period()),lpRect)) { SizeX = (lpRect[2]-42) - (lpRect[0]+5); SizeY = (lpRect[3]-21) - (lpRect[1]+5); } else return(false); int PXperBar = (SizeX/WindowBarsPerChart()/2)*2; if(PXperBar<1) PXperBar=1; int Selected_Bar = WindowFirstVisibleBar() - NormalizeDouble((X-0.0)/PXperBar,0); double PXperPoint = SizeY/((WindowPriceMax()-WindowPriceMin())/Point); Price = NormalizeDouble(WindowPriceMax() - Y/PXperPoint*Point ,Digits); //if(Selected_Bar<0) Selected_Bar=0; Bar = Selected_Bar; if(Price>Point) return(true); else return(false); } datetime i_Time(string Sym, int Per, int bar) { if(StringLen(Sym)<3) Sym=Symbol(); if(Per==0) Per=Period(); if(bar>=0) return(iTime(Sym,Per,bar)); int i=0; bool sat=false, sun=false; datetime result = iTime(Sym,Per,0); for(int p=0; p<7; p++) { if( TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,p))==6 ) sat=true; if( TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,p))==0 ) sun=true; } while(i>bar) { result += Per*60; if((TimeDayOfWeek(result)==0 && !sun) || (TimeDayOfWeek(result)==6 && !sat)) continue; i--; } return(result); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Question about OBJ_TRIANGLE
can this type of object be moved around and positioned on the chart using 3 coordinates with
ObjectSet(obj_name, OBJPROP_XDISTANCE,x_coor);
ObjectSet(obj_name, OBJPROP_XDISTANCE,x_coor);
.. to achieve a positioning relative to left+top corner of sequrity window as with "Label" here: https://book.mql4.com/functions/objects
i don't see how this can be possible, since the "three coordinates" are https://docs.mql4.com/objects/ObjectCreate Price+Time
note: this is not a question about ARROWS whether on the chart or indicator - this is about triangles that you create via CreateObject(... with type set to OBJ_TRIANGLE