GetPrice

See Also...

Related Topics

 

 

Description

This formula enables you to retrieve any of a variety of price elements.

 

 

Formula

GetPrice(instrument, bate, targetBar, Periods)=begin

  targetBar = targetBar - 1

  retval = 0

  if bate == BATE_CLOSE then retval = vchart(instrument.last[targetBar])

  if bate == BATE_OPEN then retval = vchart(instrument.open[targetBar])

  if bate == BATE_HIGH then retval = vchart(instrument.high[targetBar])

  if bate == BATE_LOW then retval = vchart(instrument.low[targetBar])

  if bate == BATE_BID then retval = vchart(instrument.bid[targetBar])

  if bate == BATE_ASK then retval = vchart(instrument.ask[targetBar])

  if bate == BATE_INDEXxCLOSE then retval = ((TOTALBARS - (targetBar+1)) + 1) * vchart(instrument.last[targetBar])

  if bate == BATE_BARINDEX then retval = ((TOTALBARS - (targetBar+1)) + 1)

  if bate == BATE_BARINDEX_SQUARED then retval = ((TOTALBARS - (targetBar+1)) + 1) ^ 2

  if bate == BATE_CLOSE_SQUARED then retval = vchart(instrument.close[targetBar]) ^ 2

  if bate == BATE_RSQUARED then retval = vchart(RSquared_1(instrument, Periods, (targetBar + 1))[targetBar])

  if bate == BATE_TRUERANGE then retval = vchart(TrueRange(instrument, (targetBar + 1))[targetBar])

  retval

end

 

 

Parameters

instrument

The instrument argument specifies which instrument to evaluate.

 

bate

The bate argument specifies the pricing element you want to retrieve. Possible values are:

 

Value

Constant

Refers to

0

BATE_REFRESH

A refresh.

1

BATE_TRADE

A trade.

2

BATE_BID

A bid.

3

BATE_ASK

An ask.

4

BATE_SETTLE

A settlement.

5

BATE_OPEN

An open.

6

BATE_CLOSE

A close, or last.

7

BATE_HIGH

A high.

8

BATE_LOW

A low.

9

BATE_INDEXxCLOSE

A product employed in the RSquared formula.

10

BATE_BARINDEX

A value employed in the RSquared formula.

11

BATE_BARINDEX_SQUARED

A value employed in the RSquared formula.

12

BATE_CLOSE_SQUARED

A value employed in the RSquared formula.

13

BATE_RSQUARED

An RSquared value.

14

BATE_TRUERANGE

A true range.

 

Note that while you can call this formula from another formula using a reference to a BATE constant, you must use a number in the parameters menu of any study or overlay formula that calls this formula.

 

targetBar

The index parameter enables you to specify the bar for which you want to retrieve volume. Use 0 to specify the current bar, 1 to specify the first bar back, 2 to specify the second bar back, etc.

 

Periods

This parameter should be set to zero (0) unless you request BATE_RSQUARED (13). If you request an RSquared value, the Periods parameter enables you to specify the length, or number of periods.

 

 

Return Value

The value you specify.

 

 

Examples

BodyMidPoint(instrument, targetBar)=begin

  retval = NONUM

  pHigh = GetPrice(instrument, BATE_HIGH, targetBar, 0)

  pLow = GetPrice(instrument, BATE_LOW, targetBar, 0)

  nvSub = Diff(pHigh, pLow) / 2

 

  if pHigh != NONUM then begin

    retval = pLow + nvSub

  end

end

 

 

Comments

NA

 

©2008 Aspen Research Group, Ltd. All rights reserved. Terms of Use.