My advice, stop wasting your development time using the raw object functions and use the standard library instead. CChartObjects (and subclasses) handle all the tear-down and error checking for you logic for you. In order to move a box you simply need to change the datetime, price coordinates.
#property strict #include <ChartObjects\ChartObjectsShapes.mqh> CChartObjectRectangle g_box; int g_width, g_height; //+------------------------------------------------------------------+ int OnInit() { g_box.Create(0, "Box", 0, 0, 0.0, 0, 0.0); g_width = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS); g_height = (int)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS); EventSetMillisecondTimer(50); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTimer() { datetime time[2] = {0}; double price[2] = {0.}; for(int i=0; i < 2; i++){ int x = rand() % g_width; int y = rand() % g_height; int sub = 0; ChartXYToTimePrice(0, x, y, sub, time[i], price[i]); } g_box.Time(0, time[0]); g_box.Time(1, time[1]); g_box.Price(0, price[0]); g_box.Price(1, price[1]); } //+------------------------------------------------------------------+ void OnTick(){}
Hello!
Could someone help me by saying how can I move objects without selecting them? I saw a video recently and found it very interesting, but it's been days and I still have not made any progress.
https://www.youtube.com/watch?v=4VyC1TahLRo ---> how can you move the equal object it does at 1:08 in the video??
it is not as easy as it sounds or appears. I agree with @nicholi shen. It is better to study library already written than to recreate the wheel.
- First you have to capture the mouse movement and click (click vs. drag)
- Second you have to bind the mouse location to the location of the panel
I suggest reading wonderful series of articles written by @Anatoli Kazharski starting from chapter 1 https://www.mql5.com/en/articles/2125 You can also study the library written by MetaTrader4 under Indicator > SimplePanel > SimplePanel (link to the library resources are within the indicator). You have to use OnChartEvent(....) function (like MetaTrader), or OnTimer(...) like @Anatoli Kazharski to capture the mouse move.
- 2016.02.01
- Anatoli Kazharski
- www.mql5.com
it is not as easy as it sounds or appears. I agree with @nicholi shen. It is better to study library already written than to recreate the wheel.
- First you have to capture the mouse movement and click (click vs. drag)
- Second you have to bind the mouse location to the location of the panel
I suggest reading wonderful series of articles written by @Anatoli Kazharski starting from chapter 1 https://www.mql5.com/en/articles/2125 You can also study the library written by MetaTrader4 under Indicator > SimplePanel > SimplePanel (link to the library resources are within the indicator). You have to use OnChartEvent(....) function (like MetaTrader), or OnTimer(...) like @Anatoli Kazharski to capture the mouse move.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
Could someone help me by saying how can I move objects without selecting them? I saw a video recently and found it very interesting, but it's been days and I still have not made any progress.
https://www.youtube.com/watch?v=4VyC1TahLRo ---> how can you move the equal object it does at 1:08 in the video??
Could someone write an example for me in this "Box" file and send me back?