Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/26/2009(UTC) Posts: 76 Location: Toronto, Canada
|
Hi guys,
I have a question that seems quite ambiguous to me. How do I refer to the opening price of the day that I enter a trade given that I have set the "Delay by one bar" option. For instance I enter at a signal of
C>Mov(C,20,s);
Now since I enter on the opening price of the next day, I want to be able to refer to this price. Any help is greatly appreciated. Thanks
VT
EDIT:
I kind of found a solution, For example:
x:= BarsSince(C>Mov(C,20,S))=1;
Valuewhen(1,x,O);
It should work for similar conditions but any further advice on the issue would be helpful. Thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi VT
I would delay the entry signal by using Ref(signal,-1) on the signal. That way the entry price is the OPEN of the entry bar and a little easier to keep track of. This approach also allows 100% of equity to be committed to a trade without fear of the trade being aborted through insufficient capital being available on the execution bar (probably not an issue for you but a common complaint from newbies ).
I'm sure you're aware that a simple latch or a basic ValueWhen() function won't help in the event of secondary entry signals though. To filter out any secondary signals (signals that inappropriately "update" the entry price) you'd need to use a PREV-based latch or one or more Simulation functions.
Roy
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/26/2009(UTC) Posts: 76 Location: Toronto, Canada
|
Hy Roy,
if my entry is:
signal:= Cross(C,Mov(C,20,S));
and I use Ref(signal,-1) wouldn't that refer to the last time the close crossed the MA?
VT
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi VT
signal:= Cross(C,Mov(C,20,S));
Ref(signal,-1);
refers to a Cross of C from below to above the 20 period SMA on the previous bar rather than it occuring on the current bar. All that has changed is that you've taken control of applying a delay of the signal by one bar. The EST is no longer controlling the execution delay until the next bar - you are.
Although it's not particularly relevant with this example, what gets many perople into trouble with the EST is that they try and structure their code and entry setups as they would in real trading. This type of thinking might have some advantages but it tricks people into trying to code from the present looking into the future (if this happens today and that happens tomorrow I'll enter a trade on the following day). A better perspective (IMHO) is to view events from the current day looking back into the past (if that happend two days ago and something else happened yesterday then I will enter the trade today). By doing that in your code there's never any reason to predict or code for possibilities. You simply use the data that's already available and certain. Feel free to disagree but it works for me.
Roy
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.