am not able to partially close a short position
Forums › ProRealTime English forum › ProOrder support › am not able to partially close a short position
- This topic has 5 replies, 2 voices, and was last updated 8 years ago by lasmiveni.
-
-
04/12/2016 at 11:06 AM #5266
I have the following code:
1234567if shortonmarket thenif countofshortshares=3 and positionperf>=X thenbuy 1 contracts at marketendifendifI want to close just 1 of 3 contracts.. but the code above, when positionperf reaches X %, closes the whole position.
According with the ProBackTest manual, it should work but it doesn’t:
Manual says, pag. 9 / 92
Entering and exiting the market
Different instructions are used depending on the type of position:
Long positions:
BUY is an enter long position instruction (Buy securities)
SELL is an exit long position instruction (Sell securities)
BUY allows you to open a long position on the market or add to an existing open position. It is associated with the instruction SELL which allows to close or partially close a position. The instruction SELL has no effect if there is no long position open.
Some advice please?
04/12/2016 at 11:46 AM #5268Hello lasmiveni,
POSITIONPERF gives you the position performance of the last N position //edited by Nicolas
Also, if you try to partially close position with IG, it is not possible as they don’t allow it actually.
In your code I don’t see anything that can close a buy or a set of buy orders. You should use SELL to close a long position.
04/12/2016 at 1:50 PM #5280am getting confused, into the manual I read the following info about PositionPerf:
PositionPerf
The instruction POSITIONPERF(n) returns:The performance (ratio gain/cost of the position) of the n-th last position closed if n>0 (not including brokerage fees)
The performance (ratio gains/cost of the position) of the currently open position if n=0 (not including brokerage fees)
…
If n is not specified, we suppose that n=0. PositionPerf=PositionPerf(0).
Can you please explain better?
good to know I can’t partially close positions with IG, even if PRT manual says I’d be able to do it.
In my code I wanted to partially close a Short Position, it should work viceversa too I guess.
04/12/2016 at 3:38 PM #5286PRT manual is the ProRealTime software manual instructions, not the way how broker deal with their proper orders books. But you’re right it is not clear in the manual for sure 🙂
About your first message of the thread, to close a SHORT position you should use EXITSHORT, not BUY which is used to open a new long position.
And for the PositionPerf behaviour, I’m gonna investigate why it is described as you mention it because I were pretty sure it were not possible to get the actual position performance …
04/12/2016 at 4:11 PM #5288Well, you were absolutely right.
1PositionPerf(0)Return the performance of the actual opened order. Sorry for inconvenience! my bad … 🙂 I have changed my first message to be clear for anyone reading this thread in the future.
04/12/2016 at 4:26 PM #5291ok, thank you Nicolas for ur quick reply,
I simply thought, since manual says I can partially close a SH or LG position, buying or selling only a certain amount of contracts,
that EXITSHORT is not the right syntax to use because sells the whole lot.
So I tryed to use just SELL… btw there’s not a right syntax here cos IG doesn’t allow to do that.
-
AuthorPosts
Find exclusive trading pro-tools on