March 7, 2006
Getting X, Y co-ordinates of Study()
The following code sample shows how to get date/time (X co-ordinate) and value (Y co-ordinate) of starting and ending point of manually drawn study.
In order to use this sample you need to follow these steps:
- open Formula Editor,
- paste code below,
- press “Apply Indicator”,
- draw a trend line on this newly inserted chart pane,
- double-click on the trend line to bring up properties dialog
- select “SU” as study ID and press OK
Plot( C, "Price", colorBlack, styleCandle );
trendline = Study("SU", GetChartID() );
StartX = LastValue( ValueWhen( ExRem( trendline, 0 ), DateTime() ) );
EndX = LastValue( ValueWhen( trendline, DateTime() ) );
StartY = LastValue( ValueWhen( ExRem( trendline, 0 ), trendline ) );
EndY = LastValue( ValueWhen( trendline, trendline ) );
if( StartX == 0 )
Title = "No trend line drawn - please draw it and use 'SU' as study ID";
else
Title = "{{NAME}} {{DATE}}n"+
"Start at X = " + WriteVal( StartX, formatDateTime ) + ", Y = " + StartY +
"nEnd at X = " + WriteVal( EndX, formatDateTime ) + ", Y = " + EndY
Filed by Tomasz Janeczko at 6:34 am under Indicators
Comments Off on Getting X, Y co-ordinates of Study()