You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In class CGraphic, I replaced the color type by uint in all places, as you asked.
Also, I added new methods to CCanvas class, which allow to draw primitives with specified thickness:
In line with the innovation of CCanvas, I extended the properties of CCurve:
When drawing a curve with lines, you can now specify the thickness of the lines and the style of its ends.
That's just awesome.
The handling of splines (interpolation with Bézier curves) has been revised. Its implementation has been moved from the CGraphics class directly into CCanvas, which allows splines to be constructed outside of the Graphics library.
In addition, an algorithm for rendering closed spline was added.
As a result, the CCanvas class now has two new public methods.
These methods allow splines to be drawn in a given style and with a given thickness.
Since Bezier curves describe circles and ellipses rather precisely, there is no obvious need to augment the CCanvas class with new methods to render these primitives with a given thickness.
The example of ellipse approximation by Bézier curves based on PolygoneSmooth method:
Result:
Another possible step towards the versatility of the Graphics library: a custom curve drawing mode CURVE_CUSTOM.
This mode will eliminate the need to inherit the CGraphic class and overload the ...Plot methods in order to draw a curve differently than the library's standard tools allow.
To implement this mode CURVE_CUSTOM new properties will be added to the CCurve class.
It is based on a new pointer to the PlotFucntion function.
This approach opens up new possibilities for drawing plots.
Let's implement drawing of candlesticks in the CGraphics library as an example:
1. Let's create a container class in which all data of a single candle will be stored.
Since the CCandle class is a descendant of the CObject class, all the candlesticks we want to draw, we can sequentially write them into the object of the CArrayObj class. This array will get into our custom drawing method as the cbdata parameter. As a result, the candlestick drawing method will look as follows.
3. For simplicity, all candlesticks will be generated randomly. And so we sequentially generate 10 candlesticks and fill the CArrayObj class object with them. Then we create CGraphics object and add one curve into it, while specifying that it will be drawn using our PlotCandles function. We also need to change the maximum and minimum values of the y-axis, so that our candles would be fully visible.
As a result, we get the following graph:
@Roman Konopelko
there is a small error in the CGraphic::SetDefaultParameters function
The colours should be initialized with opacity taken into account.
@Roman Konopelko
there is a small error in the CGraphic::SetDefaultParameters function
Colours should be initialized with opacity taken into account.
This example caused the computer to freeze. What I did: after putting the indicator on the chart in the editor, I played with different combinations of commenting/uncommenting lines 87 and 88 (when one at a time, when together)
Repeated the achievement twice. I have not recorded the sequence of actions. Third time is trivial I'm afraid to check.
Added: build 1607 x64
This example caused the computer to freeze. What I did: after putting the indicator on the chart in the editor, I played with different combinations of commenting/uncommenting lines 87 and 88 (when one at a time, when together)
Repeated the achievement twice. I have not recorded the sequence of actions. Third time is trivial I'm afraid to check.
Added: build 1607 x64
Repeated the record today - dead computer hangs, managed to see RAM consumption rise from 2GB to 5.5GB. Seems to have managed to close the schedule, but the computer has been hanging for five minutes.
This time I put a limit on the size of the array - not more than 300 elements. As you can see it didn't help 🤔
what does debug say?
what does debug say?
Jbug didn't get it, I did this: hovered an indicator and uncommented/commented one or two lines and compiled. Ended up writing from a tablet, laptop went out...
The gbug didn't make it, I did this: I hovered over the indicator and commented out/commented one or two lines and compiled. Ended up writing from a tablet, laptop went out...
So, laptop after hard reboot came back to life, but I don't want to conduct further destructive experiment - there are several Expert Advisors running on the laptop, so there is no desire to catch a freeze for a whole hour.