Can you do an "and then" command using rules?
Author: rob.house
Creation Date: 10/4/2012 5:02 PM
profile picture

rob.house

#1
Hi,

I'm trying to create a rule that that basically say if there have been n number or more consecutive up bars "and then" a down bar, the sell. I'm not a programmer so wouldn't have a clue with script and couldn't find a way to do it with rules. It didn't work adding both conditions separately (consecutive bars and turn down).

Anyone got any ideas?


Thanks,

Rob
profile picture

Eugene

#2
Hi Rob,

One can easily do it in code following this design pattern: WealthScript Techniques | Setups, Triggers, Delays, and Timeouts

In rules, the way to do it is the "Multi-Condition Group" condition (Help menu - User Guide > Strategy Window > Strategy Builder > MC, Multi-Condition Group).

Note the order:

1. The Price Decrease rule is placed on top of the MC Group because this condition is evaluated on the last bar. Set the Lookback period to "1".
2. Then goes the "divider": the Muti-Condition Group rule. Leave "Required conditions" at "1", set "Lookback period" as you like but more than 1 (e.g. 3) to capture price activity preceding the down bar.
3. Finally, the Price Increase rule. Set the "Lookback period" to "1" (this makes it consecutive), the "n down bars" is the "Number of bars" field (e.g. 3).

There you have it. Note: in this setup, consecutive bars up are counted without consideration of the date when your position has been entered. In code, this can be adjusted.
profile picture

rob.house

#3
Thanks for that Eugene, appreciated.

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