GetCurrentBid()

View as Markdown

Definition

Returns the current real-time bid price.

Notes:

  1. When accessed during State.Historical, the Close price of the evaluated bar is substituted. To access historical bid prices, please see Developing for Tick Replay.
  2. The GetCurrentBid() 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 bid price.

Syntax

GetCurrentBid()

GetCurrentBid(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 GetCurrentBid() on historical data
4 if (State == State.Historical)
5 return;
6
7 double currentBid = GetCurrentBid();
8 Print("The Current Bid price is: " + currentBid);
9 // The Current Bid price is: 1924.75
10}
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 primaryBid = GetCurrentBid(0);
23 Print("The Primary Bid price is: " + primaryBid);
24 // The Primary Bid price is: 1924.75
25 }
26
27 if (BarsInProgress == 1)
28 {
29 double msftBid = GetCurrentBid(1);
30 Print("MSFT's Current Bid price is: " + msftBid);
31 // MSFT's Current Bid is: 43.63
32 }
33}