Skip to content

ChartAndrewsPitchfork.CalculateY

method · ChartAndrewsPitchfork · cAlgo.API Since 5.8

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)
chartAndrewsPitchfork.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 pitchfork = Chart.DrawAndrewsPitchfork("pitchfork", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(20), Bars.HighPrices.Last(20), Bars.OpenTimes.Last(10), Bars.LowPrices.Last(10), Color.Red);
var medianValue = pitchfork.CalculateY(Bars.Count - 1);
Print("Median line value at the last bar: {0}", medianValue);
pitchfork = api.Chart.DrawAndrewsPitchfork("pitchfork", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(20), api.Bars.HighPrices.Last(20), api.Bars.OpenTimes.Last(10), api.Bars.LowPrices.Last(10), Color.Red)
medianValue = pitchfork.CalculateY(api.Bars.Count - 1)
api.Print(f"Median line value at the last bar: {medianValue}")

CalculateY(DateTime time)

Calculates Y-axis value corresponding the specified time value.

double CalculateY(DateTime time)
chartAndrewsPitchfork.CalculateY(time: DateTime) -> float

Parameters

Name C# type Python type Description
time DateTime DateTime The time.

Returns double — Y-axis value

Examples

var pitchfork = Chart.DrawAndrewsPitchfork("pitchfork", Bars.OpenTimes.Last(30), Bars.LowPrices.Last(30), Bars.OpenTimes.Last(20), Bars.HighPrices.Last(20), Bars.OpenTimes.Last(10), Bars.LowPrices.Last(10), Color.Red);
var medianValue = pitchfork.CalculateY(Bars.OpenTimes.LastValue);
Print("Median line value at {0}: {1}", Bars.OpenTimes.LastValue, medianValue);
pitchfork = api.Chart.DrawAndrewsPitchfork("pitchfork", api.Bars.OpenTimes.Last(30), api.Bars.LowPrices.Last(30), api.Bars.OpenTimes.Last(20), api.Bars.HighPrices.Last(20), api.Bars.OpenTimes.Last(10), api.Bars.LowPrices.Last(10), Color.Red)
medianValue = pitchfork.CalculateY(api.Bars.OpenTimes.LastValue)
api.Print(f"Median line value at {api.Bars.OpenTimes.LastValue}: {medianValue}")