Exit on stop or profit target
Author: fibonaccitrader
Creation Date: 11/30/2010 12:03 PM
profile picture

fibonaccitrader

#1
Would you be able to provide me with basic code that would (once long a position):

Exit in 1 of 2 ways:
1) Stop loss which is triggered when the 50 day MAV turns down (prior it is trending up).
2) Profit target = 100 day MAV (stock is currently below the 100d MAV).

Thanks.
profile picture

Cone

#2
What is the stop loss level? Do you mean to simply exit the Position when the 50 dma turns down?
profile picture

Eugene

#3
The rules aren't entirely clear to me. Hope that helps.
CODE:
Please log in to see this code.
profile picture

fibonaccitrader

#4
This is helpful, thank you very much. However, more specifically, I would like the SellAtLimit to occur at the 50 MAV and be entered as a limit order each bar. I.e. I do not want to have to wait until it crosses and then sell the position on the next bar. I want the order to be in as a limit order at the 50 MAV.
Does that make sense?
Thanks for your help.
profile picture

Eugene

#5
Yes, makes sense. Comment the line with the condition.
profile picture

fibonaccitrader

#6
Perfect thanks.
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).