ChartTrendLine.CalculateY
method · ChartTrendLine · cAlgo.API
DesktopCLICloud
Calculates Y-axis value corresponding the specified bar index.
Environment behaviour
CLI — works differently. Created and kept with all its properties, but never drawn: the CLI displays no chart.
Cloud — works differently. Created and kept with all its properties, but never drawn: the cloud displays no chart.
Overloads
| Signature | Description |
|---|---|
CalculateY(int barIndex) | Calculates Y-axis value corresponding the specified bar index. |
CalculateY(DateTime time) | Calculates Y-axis value corresponding the specified time value. |
CalculateY(int barIndex)
Calculates Y-axis value corresponding the specified bar index.
double CalculateY(int barIndex)
chartTrendLine.CalculateY(barIndex: int) -> float
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
barIndex | int | int | Index of the bar. |
Returns double — Y-axis value
Examples
var trendLine = Chart.DrawTrendLine("support", Bars.OpenTimes.Last(20), Bars.LowPrices.Last(20), Bars.OpenTimes.Last(10), Bars.LowPrices.Last(10), Color.Red);
trendLine.ExtendToInfinity = true;
var supportValue = trendLine.CalculateY(Bars.Count - 1);
if (Bars.ClosePrices.LastValue < supportValue)
Print("Price closed below the support trend line at {0}", supportValue);
trendLine = api.Chart.DrawTrendLine("support", api.Bars.OpenTimes.Last(20), api.Bars.LowPrices.Last(20), api.Bars.OpenTimes.Last(10), api.Bars.LowPrices.Last(10), Color.Red)
trendLine.ExtendToInfinity = True
supportValue = trendLine.CalculateY(api.Bars.Count - 1)
if api.Bars.ClosePrices.LastValue < supportValue:
api.Print(f"Price closed below the support trend line at {supportValue}")
CalculateY(DateTime time)
Calculates Y-axis value corresponding the specified time value.
double CalculateY(DateTime time)
chartTrendLine.CalculateY(time: DateTime) -> float
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
time | DateTime | DateTime | The time. |
Returns double — Y-axis value
Examples
var trendLine = Chart.DrawTrendLine("resistance", Bars.OpenTimes.Last(20), Bars.HighPrices.Last(20), Bars.OpenTimes.Last(10), Bars.HighPrices.Last(10), Color.Red);
trendLine.ExtendToInfinity = true;
var resistanceValue = trendLine.CalculateY(Server.Time);
Print("Resistance trend line value now: {0}", resistanceValue);
trendLine = api.Chart.DrawTrendLine("resistance", api.Bars.OpenTimes.Last(20), api.Bars.HighPrices.Last(20), api.Bars.OpenTimes.Last(10), api.Bars.HighPrices.Last(10), Color.Red)
trendLine.ExtendToInfinity = True
resistanceValue = trendLine.CalculateY(api.Server.Time)
api.Print(f"Resistance trend line value now: {resistanceValue}")