Take position afte x bars if condition didn't reverse since trigger
Author: Harapa
Creation Date: 7/26/2015 11:36 AM
profile picture

Harapa

#1
Few things that I would like to improve in this code:
1. The code executes at bar + X (X =10 in this case) but ignores if between 0-10 bars signal reversed. How I can force the code to execute if only original signal isn't reversed before arriving at execution bar.
2. Like to test impact of opening 1/3 of position whenever each of MADx is triggered
3. Lastly open/close position when all three MADs are in agreement (i.e >0 for entry and < 0 for exit).
Any help to incorporate the above will be greatly appreciated.
------------

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

Eugene

#2
1. It's incorrect to pass anything more than "+1" when specifying the signal bar i.e. it should be either "bar" for AtClose or "bar+1" for anything else. Here's the proper pattern to introduce a delay in your trading system:

WealthScript Techniques | Setups, Triggers, Delays, and Timeouts

2. Please see Knowledge Base > WealthScript Techniques | Pyramiding (Adding to position).

3. This should help: WealthScript Programming Guide > DataSeries > Accessing a Single Value from a DataSeries
profile picture

Harapa

#3
Thanks for the suggestion.
profile picture

Harapa

#4
Here is what I got to work. The setup now waits till last 5 bars are > or < Zero.
I don't know if using & instead of && makes a difference!
(I couldn't figure out a way to incorporate solution proposed in #1. May be next time...)
I am sharing this for the community ;)

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