GetCurrentAsk()

View as Markdown

Definition

Returns the current real-time ask price.

Notes:

  1. When accessed during State.Historical, the Close price of the evaluated bar is substituted. To access historical Ask prices, please see Developing for Tick Replay.
  2. The GetCurrentAsk() method runs on the bar series currently updating determined by the BarsInProgress property. For multi-instrument scripts, an additional int barsSeriesIndex parameter can be supplied which forces the method to run on an supplementary bar series.

Method Return Value

A double value representing the current ask price.

Syntax

GetCurrentAsk()

GetCurrentAsk(int barsSeriesIndex)

Parameters

ParameterDescription
barsSeriesIndexAn int value determining the bar series the method runs. Note: This optional parameter is reserved for multi-instrument scripts

Examples

1protected override void OnBarUpdate()
2{
3 // Ensure we do not call GetCurrentAsk() on historical data
4 if (State == State.Historical)
5 return;
6
7 double currentAsk = GetCurrentAsk();
8
9 Print("The Current Ask price is: " + currentAsk);
10
11 // The Current Ask price is: 1924.75
1protected override void OnStateChange()
2{
3 if (State == State.SetDefaults)
4 {
5 Name = "Example's Indicator";
6 }
7 if (State == State.Configure)
8 {
9 //Add MSFT as our additional data series
10 AddDataSeries("MSFT", BarsPeriodType.Minute, 1);
11 }
12}
13
14protected override void OnBarUpdate()
15{
16 // Ensure we do not call GetCurrentBid() on historical data
17 if (State == State.Historical)
18 return;
19
20 if (BarsInProgress == 0)
21 {
22 double primaryAsk = GetCurrentAsk(0);
23 Print("The Primary Ask price is: " + primaryAsk);
24 // The Primary Ask price is: 1924.75
25 }
26
27 if (BarsInProgress == 1)
28 {
29 double msftAsk = GetCurrentAsk(1);
30 Print("MSFT's Current Ask price is: " + msftAsk);
31 // MSFT's Current Ask is: 43.63
32 }