Entering Stop orders when a trade has been stopped out
Author: pholding2001
Creation Date: 2/17/2021 2:16 PM
profile picture

pholding2001

#1
Hi,

I have a simple long/short reversal system with 3xATR stops.

When a position has been stopped out, I would like to add an order to reenter the trade at the original price, in the original direction with a 3xATR stop. If price reaches the original entry price, I would like a new trade to be triggered. If, however, a new trade is entered in the opposite direction, I would like the order to be cancelled. Is that something you could help me with?

Many thanks

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

Eugene

#2
Hi,

Here's sample code of a simple long-only system to make a reentry on your conditions. Didn't have time to test it too much though. Reentry for a SAR type of system would be less intuitive and harder to manage so I'm not going to approach this.

Note that your draft code should not be used due to various errors (from syntax to peeking into the future).

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

Eugene

#3
P.S. This may be of some help as well:

Reentry after stop loss
profile picture

pholding2001

#4
Hi Eugene,

Thanks for your help. It sounds like what I'm trying to do is quite difficult. I'll see what I can do.

Regarding your comment:

"Note that your draft code should not be used due to various errors (from syntax to peeking into the future)."

I've gone over the code and cannot see where the problems lie. Can you be more specific? I'm looking to open/close trades in the last 10 mins of the session when there is a cross over (which is of course not confirmed until the close). Is this what you mean by peeking into the future?

And regarding syntax errors, my limited experience is not letting me see them. Can you be more specific?

Cheers
profile picture

Eugene

#5
1. Missing braces here (and more):
CODE:
Please log in to see this code.


The resulting signals will not make sense even if you fix this - it's more than a simple fix.

2. Peeking into the future with bar+0 for anything but AtClose:
CODE:
Please log in to see this code.


Suggestion: break your system into two (long and short) strategies so that it would be easier for you to code.
profile picture

pholding2001

#6
Good idea. Thanks Eugene.
profile picture

Eugene

#7
Glad to help you Paul. Let me know if further coding advice or review is required.
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).