Hi
Lets say I draw and Free Line or Trend Line on chart, is it possible to print the angle of trend line on chart?
For example After I draw a Trend Line, it should print the angle of line on the chart itself
View attachment 39529
By angle I mean degree angle or in degrees
Lets say I draw and Free Line or Trend Line on chart, is it possible to print the angle of trend line on chart?
For example After I draw a Trend Line, it should print the angle of line on the chart itself
View attachment 39529
By angle I mean degree angle or in degrees
Sir just use this code and double click on drawn line and give study id as ZZ, you will see angle of drawn line in Title.
Code:
drawnline = Study( "ZZ", GetChartID() );
x0 = LastValue( ValueWhen( ExRem( drawnline, 0 ), BarIndex() ) );
x1 = LastValue( ValueWhen( drawnline, BarIndex() ) );
y0 = LastValue( ValueWhen( ExRem( drawnline, 0 ), drawnline ) );
y1 = LastValue( ValueWhen( drawnline, drawnline ) );
if( x0 != 0 )
{
slope = ( y1 - y0 ) / ( x1 - x0 );
angle = atan( slope );
angle_in_degrees = angle * 180 / 3.14 ;
Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) + "\nAngle of drawn line is " + angle_in_degrees + " °";
}
Good Luck