Establish just one open Position despite successive conditions
Author: ajrdwv07
Creation Date: 3/10/2017 12:23 PM
profile picture

ajrdwv07

#1
Hello, I have the following question:
Imagine you have two triggers to go long. for example
a) CrossOver(bar, rsi, 20) go Long
b) If CrossUnder(bar, rsi, 50), close Long
c) if CrossOver(bar, rsi, 60) go long again
If rsi goes from a -> b -> c you have just one position on.
However, if rsi go straight from 20 to 100, I have two long positions open. How can I do, to say to WL that if I have one position open (same direction than trigger) don't open a new one and keep just one.

profile picture

Eugene

#2
Hello,

With the standard single-position template you cannot have two positions open since condition "b)" has a chance to happen on the bar following "a)" at best, and only then comes "c)". So what you're not saying is that this is a multi-position strategy.

There are many ways to prevent entry at "c)".

1. You could, for example, set a boolean condition "canEnter" to false once entry "a)" has taken place.
2. Another way is to check at step "c)" that the Position created by BuyAt*/ShortAt* at "a)" is not null.
3. Third way is to assign each signal a name and query the ActivePositions collection before opening the "c)" Position that the "a)" doesn't exist.
4. Not sure if setting "Max positions in symbol" from Position Options to 1 is applicable but I'm sure there are more options.
profile picture

ajrdwv07

#3
Thanks Eugene, I will digest and make my homework. You gave me good clues. rgds.