Can't is a word i don't like in my vocabulary. Is there no library i can use to get the pixel coordinates of the points on the chart??.
Can't is a word i don't like in my vocabulary. Is there no library i can use to get the pixel coordinates of the points on the chart??.
OK, you can . . . but it makes zero logical sense.
What might make sense is to calculate the slope . . . gradient if you like . .
Other than that, you can get the window size in pixels using . . .
#import "user32.dll" int GetWindowRect(int hWnd, int rect[4]); // Get window dimensions (x,y -> x,y) #import int WindowDims[4]; // used to store window coordinates from "user32.dll" if (IsDllsAllowed()) { GetWindowRect(WindowHandle(Symbol(), Period()), WindowDims); SizeX = WindowDims[2] - WindowDims[0]; SizeY = WindowDims[3] - WindowDims[1]; } else Print("DLLs not allowed ! !");
and the window price max and min with the WindowPriceMax() WndowPriceMin() functions . . . and the bar numbers from WindowsBarPerChart() and WindowFirstVisibleBar() . . . and then when you change timeframe or zoom you can calculate all this lot all over again to get the new meaningless angle . . . enjoy.
And by the same logic so does the angle because all triangles on the same slope have the same angle. Right?
Exactly. In situations were there exists an angle (because x and y are of the same dimension) then there would be a fixed relationship between slope and the angle and same slope would result in same angle. But since in the chart there exists no meaningful definition of angle you only have the slope but you can use the slope for all intents and purposes you would otherwise have wanted to use an angle.
The dimension of the slope would be something like dPrice/dt (for example pips per day) which makes perfect sense and its meaning is intuitive to understand and also used elsewhere where the rate of growth of something is measured.
Exactly. In situations were there exists an angle (because x and y are of the same dimension) then there would be a fixed relationship between slope and the angle and same slope would result in same angle. But since in the chart there exists no meaningful definition of angle you only have the slope but you can use the slope for all intents and purposes you would otherwise have wanted to use an angle.
The dimension of the slope would be something like dPrice/dt (for example pips per day) which makes perfect sense and its meaning is intuitive to understand and also used elsewhere where the rate of growth of something is measured.
What do you think what will happen with zoom in and zoom out with WindowPriceMax() WndowPriceMin()
if (IsDllsAllowed())
{
GetWindowRect(WindowHandle(Symbol(), Period()), WindowDims);
int SizeX = WindowDims[2] - WindowDims[0];
int SizeY = WindowDims[3] - WindowDims[1];
}
else
Print("DLLs not allowed ! !");
double Pixels_Per_Point=SizeY/((WindowPriceMax()-WindowPriceMin())/Point);
double Pixels_Per_Bar=SizeX/WindowBarsPerChart();
double Price_1=iClose(Symbol(),0,WindowBarsPerChart()-1),Price_2=iClose(Symbol(),0,1),
Point_Diff=(Price_2-Price_1)/Point;
int Bar_Diff=WindowBarsPerChart()-1;
double Point_Diff_In_Pixels=Point_Diff*Pixels_Per_Point,
Bar_Diff_In_Pixels=Bar_Diff*Pixels_Per_Bar;
if(Point_Diff > 0){
Angle=57.2957795*MathArctan(Point_Diff_In_Pixels/Bar_Diff_In_Pixels);
Print("Buy trend at ",Angle," degrees");
return;
}
else{
Angle=MathAbs(57.2957795*MathArctan(Point_Diff_In_Pixels/Bar_Diff_In_Pixels));
Print("Sell trend at ",Angle," degrees");
return;
}
- 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,
I'm trying to calculate the angle of a trend. I've tried using the price difference in points as the height of the triangle formed and the number of periods as the base then finding the tangent inverse but since the height and the base are fundamentally measured in different units i feel my results is not accurate. Some one please advise me.