{"id":8,"date":"2006-03-07T06:34:02","date_gmt":"2006-03-07T11:34:02","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/2006\/03\/07\/getting-x-y-co-ordinates-of-study\/"},"modified":"2014-12-04T08:27:45","modified_gmt":"2014-12-04T13:27:45","slug":"getting-x-y-co-ordinates-of-study","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2006\/03\/07\/getting-x-y-co-ordinates-of-study\/","title":{"rendered":"Getting X, Y co-ordinates of Study()"},"content":{"rendered":"

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:<\/p>

  1. open Formula Editor,<\/li>
  2. paste code below,<\/li>
  3. press “Apply Indicator”, <\/li>
  4. draw a trend line on this newly inserted chart pane, <\/li>
  5. double-click on the trend line to bring up properties dialog<\/li>
  6. select “SU” as study ID and press OK<\/li><\/ol>Plot<\/span>( <\/span>C<\/span>, <\/span>"Price"<\/span>, <\/span>colorBlack<\/span>, <\/span>styleCandle <\/span>);

    <\/span>trendline <\/span>= <\/span>Study<\/span>(<\/span>"SU"<\/span>, <\/span>GetChartID<\/span>() );

    <\/span>StartX <\/span>= <\/span>LastValue<\/span>( <\/span>ValueWhen<\/span>( <\/span>ExRem<\/span>( <\/span>trendline<\/span>, <\/span>0 <\/span>), <\/span>DateTime<\/span>() ) );
    <\/span>EndX <\/span>= <\/span>LastValue<\/span>( <\/span>ValueWhen<\/span>( <\/span>trendline<\/span>, <\/span>DateTime<\/span>() ) );
    <\/span>StartY <\/span>= <\/span>LastValue<\/span>( <\/span>ValueWhen<\/span>( <\/span>ExRem<\/span>( <\/span>trendline<\/span>, <\/span>0 <\/span>), <\/span>trendline <\/span>) );
    <\/span>EndY <\/span>= <\/span>LastValue<\/span>( <\/span>ValueWhen<\/span>( <\/span>trendline<\/span>, <\/span>trendline <\/span>) );

    if( <\/span>StartX <\/span>== <\/span>0 <\/span>)
      <\/span>Title <\/span>= <\/span>"No trend line drawn - please draw it and use 'SU' as study ID"<\/span>;
    else
      <\/span>Title <\/span>= <\/span>"{{NAME}} {{DATE}}n"<\/span>+
      <\/span>"Start at X = " <\/span>+ <\/span>WriteVal<\/span>( <\/span>StartX<\/span>, <\/span>formatDateTime <\/span>) + <\/span>", Y = " <\/span>+ <\/span>StartY <\/span>+
      <\/span>"nEnd at X = " <\/span>+ <\/span>WriteVal<\/span>( <\/span>EndX<\/span>, <\/span>formatDateTime <\/span>) + <\/span>", Y = " <\/span>+ <\/span>EndY<\/span><\/code>","protected":false},"excerpt":{"rendered":"

    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.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[53,55],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/8"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":1,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":796,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/8\/revisions\/796"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}