Canvas is cool! - page 96

 
Nikolai Semko #:
I guess if R>G && R>B, it's a red hue.
Though of course it is very conditional.
After all, colour 0xFfFE00 is obviously yellow, not red.
Then we should introduce the ratio of colours (G/R, B/R). But even in this case there can be mishaps. For example, colour 0xFFFBFBFB is obviously red, but when applying the ratio it will be not red enough.
And it is not clear whether orange is red?
In short, a very subjective task.
 
Denis Kirichenko #:
I need to select from all RGB colours, for example, all colours with red tint. In other words, all colours that are related to red. I know that there are 16.7 million colours. Is there any simple approach to such a task? Thank you.

If by simple, then if R=255 and G<B, the colours will be with red tint.

And if it is complicated, then you can train neuronka on examples demonstrating the desired colour range, and then use the model as a detector of the desired hue)).

 

for curiosity's sake, I looked up how to do it ...

it's elementary :-)

using a formula to determine that the colour is close to the chosen red and voila :-))

(wikipedia https://ru.wikipedia .org/wiki/Формула_цветового_отличия )

 
All colours with a component R not equal to zero will have a red tint. Though outwardly, at small value of R, they can be not at all similar to red colour, however if value of R gradually increases, it is possible to see clearly as in initial colour red shade comes through. The task is elementary. )
 
Andrey Dik #:

Simply put, if R=255 and G<B, the colours will have a red tint.

You can even check this way with wider coverage:

G < B < R: red tones

B < R == G: yellow

...and so on, not only for the basic three colours, but also for their combinations.

 
Perhaps we should add that not only increasing the value of the R component enhances the red hue, but also decreasing the values of the G and/or B components.

However, not all shades of red can/want to be interpreted as such by the brain. One can hardly find a red hue in a pure yellow colour, even though the value of the R component in it is maximal. The same applies to pure white colour. And in any grey colour there is a red tint throughout the whole range from white to black. In general, as Nicholas said above, the perception of shades is a subjective thing.

There is hardly any formula for calculating the colours of the red hue in the "subjective" spectrum. Indeed, neuronics could help..... but is it worth it? For professional design, perhaps yes.
 

Just ask GPT4o or another new neuron to write a piece of code to determine the shade of red in Python or C++, you'll figure it out from there

I won't paste it here, but the AI did it.

 
Vitaliy Kuznetsov #:

Just ask neuron GPT4o or another new one to write a piece of code to determine the shade of red in python or C++, you'll figure it out from there

I won't paste it here, but the AI did it.

No. It's not up to the task yet.
It's gonna be very slow.
It's just a couple of lines of code after the problem is clarified.
 

Canvas is cool - but just theoretically!

Why? None of the shown examples are realistic, since you have to check the chart frequently by yourself in the code, actually every tick, since the CHARTEVENT_CHART_CHANGE isn´t fired when the chart changes in many cases. On such case is, when new candles are growing at the very bottom of the chart downwards or at the very top upwards. In that moment and in case you are using CCanvas within the chart area, it all becomes invalid, not one price matches anymore. 

And to keep it accurate, you need to use ChartGetInteger or ChartGetDouble for max- or min-price and even other chart-metrics data, every tick. BUT: One single call of that function needs up to thousands of milliseconds. And naturally a bunch of calls take seconds and simply freezes everything. 

I don't understand why this thing is still not fixed. Neither the missing events, nor the timing issue. And why, for such fundamentally important stuff like the chart metrics, which you simply need for visual accuracy, why isn´t there a struct with all the metrics data at once at least, when its a fact, that there is timing problem with every single call? 

Check this - six years ago, no one cares.

https://www.mql5.com/en/forum/326220

CHARTEVENT_CHART_CHANGE - Missing events (Bug?)
CHARTEVENT_CHART_CHANGE - Missing events (Bug?)
  • 2019.11.11
  • Doerk Hilger
  • www.mql5.com
Hi, my understanding of logic regarding this event is, that it is sent when the chart changes. But it does not in many circumstances in MT5: 1...
 
Doerk Hilger #:

Canvas is cool , but only in theory!

Why? None of the above examples is realistic, because in the code you have to check the chart yourself often, actually every tick, because in many cases CHARTEVENT_CHART_CHANGE is not triggered when the chart changes. One of such cases is the growth of new candles at the very bottom of the chart downwards or at the very top upwards. At this point and in the case of using CCanvas in the chart area, everything becomes invalid, no price matches anymore.

And to maintain accuracy, you need to use ChartGetInteger or ChartGetDouble for max- or min-price and even other chart metric data, every tick. BUT: A single call to this function takes up to a thousand milliseconds. And a bunch of calls naturally takes seconds and just freezes everything.

I don't understand why this thing still hasn't been fixed. Neither the missing events, nor the timing problem. And why for fundamentally important things like graph metrics, which are needed just for visual accuracy, why isn't there a structure with all metrics data at once, if it's a fact that there's a timing problem with every call?

Check this out - six years ago, nobody cares.

https://www.mql5.com/en/forum/326220

Seconded. I also encountered a delay in CHARTEVENT_CHART_CHANGE events. Also, when switching charts, the standard ChartGetInteger function returns incorrect chart sizes. It happens as follows: when switching the chart, the CHARTEVENT_CHART_CHANGE event comes to the OnChartEvent() function more than once and returns incorrect chart sizes in one of the calls of this function. I will write a code to reproduce it in my spare time.