Employing SplitPosition in my code
Author: karla2010
Creation Date: 2/9/2011 8:23 AM
profile picture

karla2010

#1
I am having trouble with SplitPosition and obviously do not understand how it works.

Here is some code that works ok and executes exit condition xrsi_1 but never executes exit condition xrsi_2. After selling 50% of my position with xrsi_1, I expected when xrsi_2 is met the other 50% would be sold but this never happens.

Any ideas what I'm doing wrong?

Note: I scale my displays differently so rsi conditions look odd but correspond to standard values.

CODE:
Please log in to see this code.
profile picture

Eugene

#2
This happens because you keep treating the system as a single-position one...
CODE:
Please log in to see this code.

...while it creates two positions with SplitPosition.

Try this example:
CODE:
Please log in to see this code.


Note: this is really looking nonsensical as RSI can't go below zero:
CODE:
Please log in to see this code.
profile picture

karla2010

#3
Eugene,

Thanks, I'll take a closer look at your example.

With regard to rsi negative. I find it easier to compare all indicators if they are scaled about zero. I always scale all my indicators around the zero line, hence the negative value.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).