Counts the number of open shares or lots.
COUNTOFPOSITION returns negative value for short orders.
Syntax:
1 |
COUNTOFPOSITION |
Example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
myMACD = MACD[12,26,9](close) short = myMACD crosses under 0 //first order IF NOT ShortOnMarket AND short THEN SELLSHORT 1 CONTRACTS AT MARKET ENDIF MAXSHARES = abs(COUNTOFPOSITION) <= 10 //let's add another order while price continue to get lower (more than 10 points) than the last order taken with a condition of 5 bars elapsed since then IF TRADEINDEX(1)>5 AND TRADEPRICE(1)-Close>10*pointsize AND ShortOnMarket AND MAXSHARES THEN SELLSHORT 1 CONTRACTS AT MARKET ENDIF SET STOP TRAILING 50 |
Is it possible to know the preview state of CountOfPositon ?
e.g. CountOfPosition[1]…
Yes it works with CountOfPosition[1].
I understand that one strategy does not impact the order even when on same instrument. Does count of position take into account any order placed by another strategy on same instrument? I am trying to use it to limit number of max orders a strategy can place and it seems to work although i have not tested it when there is already order from another strategy??
COUNTOFPOSITION only return the count of position of the current strategy, not all the other ones opened by the strategies you run on your account with ProOrder.
This only appears to work if you are working with single contract sizes, as soon as you have multiples, it works similar to countoflongshares. it seems to count the shares and not the positions. Is there anyway of getting back to the number of positions by any chance?