Login Page - Create Account

Support Board


Date/Time: Fri, 19 Apr 2024 04:56:04 +0000



[User Discussion] - sierra chart visible chart price

View Count: 1593

[2018-03-22 13:39:04]
User79074 - Posts: 105
Is there a way to get the top and bottom price that the chart is showing? The price range that the chart is showing?
Date Time Of Last Edit: 2018-03-22 14:06:30
[2018-03-22 18:20:44]
JoseyWales - Posts: 67
Not sure if you wanted it as a Dll or as an ACSIL example, but this is something I came up with. Dll attached below.


#include "sierrachart.h"

SCDLLName("High/Low Values For Visible Bars")

SCSFExport scsf_HighLowValuesForVisibleBars(SCStudyInterfaceRef sc)
{
  SCSubgraphRef High = sc.Subgraph[0];
  SCSubgraphRef Low = sc.Subgraph[1];

  if (sc.SetDefaults)
  {
    sc.AutoLoop = 0;
    sc.GraphName = "High/Low Values For Visible Bars";
    sc.GraphRegion = 0;
    sc.UpdateAlways = 1;

    // Graphs

    High.DrawStyle = DRAWSTYLE_VALUE_ON_HIGH;
    High.Name = "High";
    High.PrimaryColor = COLOR_GREEN;

    Low.DrawStyle = DRAWSTYLE_VALUE_ON_LOW;
    Low.Name = "Low";
    Low.PrimaryColor = COLOR_RED;

    return;
  }

  const int numberOfVisibleBars = sc.IndexOfLastVisibleBar - sc.IndexOfFirstVisibleBar + 1;

  int& indexOfPreviousHighestValue = sc.GetPersistentInt(0);
  const int indexOfHighestValue = sc.GetIndexOfHighestValue(sc.High, sc.IndexOfLastVisibleBar, numberOfVisibleBars);

  if (indexOfPreviousHighestValue != indexOfHighestValue)
  {
    High[indexOfPreviousHighestValue] = 0;
    indexOfPreviousHighestValue = indexOfHighestValue;
  }

  int& indexOfPreviousLowestValue = sc.GetPersistentInt(1);
  const int indexOfLowestValue = sc.GetIndexOfLowestValue(sc.Low, sc.IndexOfLastVisibleBar, numberOfVisibleBars);

  if (indexOfPreviousLowestValue != indexOfLowestValue)
  {
    Low[indexOfPreviousLowestValue] = 0;
    indexOfPreviousLowestValue = indexOfLowestValue;
  }

  High[indexOfHighestValue] = sc.High[indexOfHighestValue];
  Low[indexOfLowestValue] = sc.Low[indexOfLowestValue];
}

Date Time Of Last Edit: 2018-03-22 18:21:20
attachmentHighLowValuesForVisibleBars_64.dll - Attached On 2018-03-22 18:19:27 UTC - Size: 84.5 KB - 335 views
[2018-03-22 19:16:18]
User79074 - Posts: 105
Thanks for the reply. What I means it I would like to know that the price on the top of the chart is 64.54 and bottom is 64.06 like in this image
imagescreen01.png / V - Attached On 2018-03-22 19:15:30 UTC - Size: 10.45 KB - 335 views
Attachment Deleted.
[2018-03-22 19:22:23]
JoseyWales - Posts: 67
Download the Dll attached above to your Sierra Chart Data folder and add the study to your chart, it should be what your looking for.
Date Time Of Last Edit: 2018-03-22 19:24:33
[2018-03-22 19:48:05]
JoseyWales - Posts: 67
I see now. The study I provided displays a value on the Highest and Lowest bars that are currently visible in the chart. It does not display the range of the current chart.

There are two variables:

sc.BaseGraphScaleRangeBottom
ACSIL Interface Members - Variables and Arrays: sc.BaseGraphScaleRangeBottom

and

sc.BaseGraphScaleRangeTop
ACSIL Interface Members - Variables and Arrays: sc.BaseGraphScaleRangeTop

However they only have valid data if the user explicitly sets them.
Date Time Of Last Edit: 2018-03-22 19:49:16
[2018-03-23 07:02:57]
User79074 - Posts: 105
Thanks, I saw that, but that only works when using a User Defined scale. If it is set to automatic, seems to be no way to get the top and bottom of the price in the scale.
[2019-04-13 08:42:59]
User735389 - Posts: 188
Try this:

        RECT rect;
        GetClientRect(sc.GetChartWindowHandle(sc.ChartNumber), &rect);
        float topValue = sc.YPixelCoordinateToGraphValue(rect.top) ;
        float bottomValue = sc.YPixelCoordinateToGraphValue(rect.bottom);

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account