Buy if price fell by Y% from the pervious open position
Author: ashish.mascot
Creation Date: 7/3/2011 12:01 AM
profile picture

ashish.mascot

#1
Dear Community members can any one help me to code below strategy:

Buy Rule:
1. Multiple open positions are allowed
2. Buy if price fell by Y% from the pervious open position any total number of open positions is not greate than z.

Sell Rule:
1. Sell if open position reach the profit target a% or position is 30 bars old

Thanks in advance :)
profile picture

Eugene

#2
Hi Ashish,

You could do it in Rule wizard entirely but one key element is missing: the buy condition. How do you enter the first open position?
profile picture

ashish.mascot

#3
Hi Eugene,

Thanks for your response

Below is the updated strategy (Added first buy conndition as well).

Buy Rule:
1. Buy the first bar at close.
2. Buy if price fell by Y% from the pervious open position and total number of open positions is not greate than z.
3. Multiple open positions are allowed

Sell Rule:
1. Sell if open position reach the profit target a% or position is 30 bars old.

Thanks and Regards,
Ashish

profile picture

Eugene

#4
Here you go.

If all positions are closed, strategy makes a reentry at the next day's close.

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

ashish.mascot

#5
Hi Eugene,

Thanks a lot for the code. Its working 90% as per my specification. I make a small change in my sell rule. Can you please help me with the code.

Sell Rule:
1. Sell if open position reach the profit target a% or Latest Open position is 30 bars old.

It will be great if you tell me the Entry and Exit conditions you use in "Rule wizard".

profile picture

Eugene

#6
I'm not using Rules.

What is the difference between "open position" and "latest open position"?
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).