Questions from Beginners MQL5 MT5 MetaTrader 5 - page 142
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
Still, I will need the variable "st" not only in Alert, but also for calculations, and when compiling the warning "possible data loss due to type conversion" comes out.
I assume this is because it turns out to be a 10-digit number, while the maximum value in int is 2 147 483 647, I currently have 1 380 758 400. Maybe it makes sense to use long, and probably the Expert Advisor will consume a lot of resources in this part?
Don't you understand the principle of type conversion? It's that simple:
I want to draw on canvas. To have a picture on canvas redrawn in OnInit, OnTimer, OnTick and in onChartEvent. I declare CCanvas canvas in global variables and call canvas.methods everywhere I want. But the compiler complains about unresolved static variable 'CCanvas::m_default_colors' (what does that have to do with colors?)
the code is like this
#include <Canvas\Canvas.mqh>
CCanvas canvas;
int OnInit()
{
//CCanvas canvas; if I declare it here, it draws but then how do I redraw it in OnTick?
canvas.CreateBitmapLabel("ProbeGraph", 0, 0, width ,heigth, COLOR_FORMAT_ARGB_RAW);
canvas.Circle(Xcentr,Ycentr,Rmin,ColorToARGB(clrBlue, 115)); canvas.Update();
}
void OnTick()
How do I negotiate with the compiler? Is there an example with canvas in expert?{
canvas.Circle(Xcentr,Ycentr,Rmin,ColorToARGB(clrBlue, 115)); canvas.Update();
}
I want to draw on canvas in Expert Advisor. I want the image on canvas to be redrawn in OnInit, OnTimer, OnTick and in onChartEvent. I declare CCanvas canvas in global variables and call canvas.methods everywhere I want. But the compiler complains about unresolved global declaration
...
How do you negotiate with the compiler? Is there an example with canvas in EA?Well you are not a beginner! Publish the code correctly!
Well you're not a beginner! Publish the code correctly!
The code is right here. But it's a lot worse to dig into. And it doesn't work either. Error unresolved static variable 'CCanvas::m_default_colors' ProbeGraph.mq5 21 9
And a heap of warrants about overlapping heigth and width variables. As far as I understand, the compiler doesn't want to call CCanvas class constructor in global variables, but wants to call the constructor at OnInit. And then how to refer to an instance of the class outside of OnInit, I do not understand.
Also. Before, the body of the Draw function was inside onInit, but the Draw itself wasn't. Everything worked, but inside OnInit. I've already started to twist here, trying to pass a reference to an instance of the class into the Draw function, because global variables don't work.
In general, the code is being written, the problem with creating a global instance of the CCanvas class.
One thing I can't understand: if the compiler swears, why aren't the errors corrected? А?
One thing I can't understand: if the compiler swears, why aren't the errors corrected? А?
Copied suggested code completely. The error is the same as unresolved static variable 'CCanvas::m_default_colors' prob1.mq5 21 9
I don't have any errors. The build is the latest.
Copied the suggested code in full. The error is the same as the unresolved static variable 'CCanvas::m_default_colors' prob1.mq5 21 9