Canvas is cool! - page 63

 
Renat Akhtyamov:

Beautiful !!!

Nikolai, please throw the code listing of the rainbow colour palette formation here

If it will be in the form of a function, it will be even more practical
I've done it many times. I'm not at my computer at the moment.
The function is called Grad.
You can find it at least in the after code of 3DSpiral
 
Nikolai Semko:

3D Moving Avarage
I'll throw the code in the Buy More tomorrow.


Nikolai, you never cease to amaze!

 

Great!

 
Used to rotate in my head) now you can look at it. Interesting thought, I thought about it for a couple of hours. What could the z-axis behaviour mean...? It looks like mountains and a plain in front of it. Like the Caucasus in Russia is the current price and the rest of the plateau is the average...)
But when viewed in space, it turns out to be a distance along the z-axis. But the distance is in what? Anyway, I haven't come up with any anologues yet, but I wonder if Nikolai did exactly what I saw in my head☺
 
Maxim Romanov:
But when viewed in space, it turns out to be a distance along the z-axis. But distance in what?
Z is the period of the MA.
In this case, all three dimensions have different magnitudes:
x - time
y - price
z is the period for calculating the arithmetic mean
their ranges are simply scaled to fit the screen size.
 

Forum on trading, automated trading systems and strategy testing

Libraries: Easy Canvas

Nikolai Semko, 2020.02.17 05:15

I want to clarify an important point for interested programmers when operating the kanvas in tester mode.
A well-known programmer in this community came to me with this question:

- Why in tester-mode my panel, created on objects is redrawn much faster than on canvas, while in normal mode my panel is drawn at normal speed on canvas?

I have managed to understand the reason for the problem and its solution.

The problem is that redrawing of objects goes together with redrawing of the whole screen, while the screen in the tester is redrawn no more frequently than 30 frames per second.

Objects are ultimately the same canvas (internal), but when you change the properties of the object, the object canvas is not generated (not recalculated), but generated only when the screen is updated (ChartRedraw), which occurs in the tester (and in normal mode, too) no more often than our eyes can distinguish changes, ie no more often than ~ 32 frames per second.

Suppose the panel changes every tick. Then the default canvas will also be redrawn every tick, but redrawing in the tester is still no more frequent than ~30 msec (~30 fps).

In other words, the canvas will be recomputed much more frequently than it is actually displayed on the screen, which results in a disproportionate use of resources.

The solution to this problem would be to ensure that canvas is recalculated and redrawn no more often than every 15-30 milliseconds of computer time, and then there will be no unnecessary cycles of empty recalculation.

For example, like this:

void OnTick()
  {
  static uint lastCalc=0;
  uint cur=GetTickCount();
  if (cur-lastCalc>15) {
    ReDrawMyCanvas();
    lastCalc=cur;
   }
  }

 
Nikolai Semko:

This should be posted in the features thread - useful.
 

Hi all, I'd like to deepen my knowledge of Canvas

I don't even know where to start. Right now I'm imagining that Canvas is complicated logarithmic formulas and stuff like that.

Can you give me an example of how to make a button like below on canvas. I need the code to understand it.


 
Vladimir Pastushak:

Hi all, I'd like to deepen my knowledge of Canvas

I don't even know where to start. Right now I'm imagining that Canvas is complicated logarithmic formulas and stuff like that.

Can you tell me how to make a button like below on a canvas as an example. I need the code to understand it.


It's easier to use a ready-made element. (as a Png image).

So it is a line with a turn another line more turn, etc.. - Then a smaller one with a fill in the form of a gradient (this is how you define fill).

On canvas you have only a primitive stripes rectangles and circles with the ability to draw the outline of our figure or line, or fill it.

So, by default, a rectangle is available that is filled in immediately.....

There is also a canvas with dots to paint your primitives (expand the class).

Probably wrote a lot of stuff you already know.


There's also a 3D canvas with vector matrices