How to program a limit sell at cross of indicator
Author: Bionian
Creation Date: 1/8/2010 12:09 PM
profile picture

Bionian

#1
The following code is a swing strategy which buys upon price retracement to the 20-day EMA. I want to sell at a limit when the price crosses the upper BBandUpper2. The way it is currently constructed, the "sell at market" exits the position at the open of that bar. How can I construct the strategy code to "sell at limit" upon the cross of the BBandUpper2? Thanks for your help.

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

Eugene

#2
CODE tags please.
profile picture

Bionian

#3
Not sure what a code tag is. Here is the entire program. Let me know what else you need. Thanks.

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

Cone

#4
Bio, the next time you post, take a look at the 7 buttons right above where you're writing. Click on the one that says "CODE" and paste your code in between.
profile picture

Eugene

#5
QUOTE:
How can I construct the strategy code to "sell at limit" upon the cross of the BBandUpper2? T

If OP talks about selling with AtLimit order when prices cross the Upper Bollinger Band intra-bar, then I'm math-disabled to know how to reverse-engineer BBs to find out the target price.
profile picture

Bionian

#6
Thanks, Cone.

The code doesn't have to be a limit order. I'm just looking to sell at the point the price crosses the upper BB for back-testing purposes. In a real trade, I would probably place a limit order on a daily basis. I just need to know how well the strategy will work. It works well as is, and selling at the open of a day in which the price later crosses the upper BB would be a conservative, albeit impossible, assumption. The limit price would generally be higher than the daily open in this case. In the case of a gap above the target price, the limit would trigger at the open.
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).