So I've been going back and forth trying to get this to work. I would love to use the PercentTrailing code with my strategy but I don't want for the order to be submitted intrabar (too many fluctuations). I would like to assess the max run-up of the position and calculate how much that max run-up has come down @ the close of the bar (not intrabar).
I tried to code this multiple ways into my strategy, but everything I've tried works nothing close to adding a "PercentTrailing" to my strategy. My attempts are below. Any suggestions would be greatly appreciated!
1) make it a condition, and when said condition triggers it would exit the position
2) Then I tried putting this at the end of my code to exit as well:
Again, non of these "solutions" worked like the true SetPercentTrailing code. Any ideas of how to work this on the close of the bar?
Thanks!
Brandon
Can you help answer these questions from other members on futures io?
when the condition for your stop is met you can send an order to close the open position, for example
This would issue the order at the end of the bar and you'd get executed around the open of the next bar. Which is to be expected when you send an order at the close.
You could fool your software (and yourself as you will create results that you can't reproduce live) by using "this bar Close" for the order, but this will likely not be the fills you get live.
You could look into custom sessions that would allow you to walk around that problem or to use intrabar order generation, which would give you the ability to close out the position near the actual bar close.