|
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:
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
retval = pLow + nvSub end end | ||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||
Comments |
NA |
©2008 Aspen Research Group, Ltd. All rights reserved. Terms of Use.