CurrentContracts: Difference between revisions
From MultiCharts
(Created page with "Returns an absolute numerical value, indicating the number of contracts or shares held in the current position. ==== Usage ==== <syntaxhighlight>CurrentContracts</syntaxhig...") |
No edit summary |
||
Line 1: | Line 1: | ||
Returns an absolute numerical value, indicating the number of contracts or shares held in the current position. | Returns an absolute numerical value, indicating the number of contracts or shares held in the current position. | ||
== Usage == | |||
<syntaxhighlight>CurrentContracts</syntaxhighlight> | <syntaxhighlight>CurrentContracts</syntaxhighlight> | ||
== Notes == | |||
This function can only be used in signals. | This function can only be used in signals. To use the CurrentContracts or [[CurrentShares]] in an indicator, see [[i_CurrentContracts]] and [[i_CurrentShares]] respectively. | ||
== Example == | |||
<syntaxhighlight>CurrentContracts</syntaxhighlight> | |||
Will return a value of "1" if the strategy is long 1 contract or share. | |||
<syntaxhighlight>CurrentContracts</syntaxhighlight> | |||
Will return a value of "5" for 5 shares short. | |||
CurrentContracts returns an absolute value for both long and short positions. Multiply it with the [[MarketPosition]] to get the negative sign for short positions. For example: | |||
<syntaxhighlight>CurrentContracts | <syntaxhighlight>MarketPosition(0) * CurrentContracts</syntaxhighlight> | ||
Will return a value of "-9" if the strategy is short 9 contracts, and will return a value of "4" if the strategy is long four contracts. | |||
[[Category:Strategy Position]] | [[Category:Strategy Position]] |
Revision as of 07:35, 4 February 2012
Returns an absolute numerical value, indicating the number of contracts or shares held in the current position.
Usage
CurrentContracts
Notes
This function can only be used in signals. To use the CurrentContracts or CurrentShares in an indicator, see i_CurrentContracts and i_CurrentShares respectively.
Example
CurrentContracts
Will return a value of "1" if the strategy is long 1 contract or share.
CurrentContracts
Will return a value of "5" for 5 shares short.
CurrentContracts returns an absolute value for both long and short positions. Multiply it with the MarketPosition to get the negative sign for short positions. For example:
MarketPosition(0) * CurrentContracts
Will return a value of "-9" if the strategy is short 9 contracts, and will return a value of "4" if the strategy is long four contracts.