N-Period Exit in Multi-Position Strategy
Author: johnls101
Creation Date: 2/18/2016 2:36 PM
profile picture

johnls101

#1
Hi

I am having difficulty getting some code to do what I want it to do.

I would like to make an entry on each bar where a certain condition is met - CumDown in the example below. This part seems fine.

However, I would then like to exit each of these positions "n" bars after each position is entered. The following code exits a cluster on the one bar which is "n" periods after the last position, rather than "n" periods after each position.

How can this be fixed to do what I want it to do?

CODE:
Please log in to see this code.

profile picture

Cone

#2
Hang on a minute, and I'll look...
profile picture

Cone

#3
Deja vu. We discussed precisely this "oversight" of the Strategy Wizard in another thread just yesterday. Click to this discussion and begin reading at my post #12 for the explanation and later a solution.

You'll have to unlock the code to fix it, so if you need more help, let me know.
profile picture

johnls101

#4
Thanks Robert. Great timing!

I'll have a look at this and get back to you if there are issues. It makes sense that it should be the current position and not the last active one.


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).