Entering new position with simultaneous stop
Author: tinman
Creation Date: 5/12/2010 10:57 AM
profile picture

tinman

#1
Hi All,

Just wondering if it's possible in WL5 to open a new position along with a stop in the SAME bar. For example, buy INTC at Open the next day (bar) but sell before the Close if it drops a certain amount.

This ability is crucial in highly volatile times like these!

Typical entry BuyAtMarket(bar + 1) doesn't know the price yet b/c that's in the "future". Then applying Stop in next iteration of the loop is too late because Close has already happened.

I tried using TrailingStop instead but it doesn't seem to work, maybe because "LastPosition" doesn't exist yet? As in:
CODE:
Please log in to see this code.


Any thoughts appreciated!

Thanks,
Mike
profile picture

Cone

#2
You've got the right idea about LastPosition, and even though I'm not familiar with SellAtAutoTrailingStop, that's the right idea too for backtesting.

However, as discussed in the User Guide: Preferences > Trading > Trading Options, Allow Same Bar Exits for Auto-Trading, you need to call RiskStopLevel for the Order Manager to work the order after a "live" entry.

So, putting it all together, the entry logic would look something like this -

CODE:
Please log in to see this code.

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