EOD / specific time exit code
Author: rmcginniss
Creation Date: 6/2/2009 10:16 AM
profile picture

rmcginniss

#1
I am a new user of Fidelity Wealth-Lab Pro 5.3. I have tried to research this in the forums and getting nowhere. I would like to set-up a simple EMA cross-over trading strategy that builds in exits at either a re-cross or at 3:55 pm, whichever comes first. I have been backtesting the strategy using EOD or re-cross and that has worked. However, I understand that cannot be executed in the live auto trade system. The question is how to replace EOD with a specific time? Thanks in advance for any help.
profile picture

Eugene

#2
Hi Rod,
QUOTE:
I would like to set-up a simple EMA cross-over trading strategy that builds in exits at either a re-cross or at 3:55 pm, whichever comes first.

Btw, what's a re-cross?

You can find an illustration of the "whichever comes first" logic in many places, such as the WealthScript Programming Guide, Programming Trading Strategies > Peeking > Order of Trading Signals (click "+" to expand code), or here:
Simple intraday system

QUOTE:
The question is how to replace EOD with a specific time?

Please see the answer at the very bottom of the WL5 Wiki FAQ:
How do I code a rule for time of the day?
profile picture

rmcginniss

#3
Thanks, Eugene. By re-cross I meant when the slow EMA crosses above the fast EMA.
profile picture

rmcginniss

#4
Call me stupid, but I cannot get the script to work. Here is specifically what I want. If anyone could help with specific code string, it would be greatly appreciated:

Strategy would use 15m bars:
Buy at Close: When fast EMA crosses above slow EMA
Sell at Close: When slow EMA crosses above fast EMA OR at 3:55 pm, whichever comes first.

That's it.

Thanks
profile picture

Eugene

#5
Here you go. But two moments first:

1. There couldn't be a 15-minute bar at 3:55pm so I assumed 3:45pm.
2. Like Robert frequently says:
QUOTE:
AtClose orders have no place in intraday trading strategies except (perhaps) at MOC - and then it's too late to get the order in. Again, the only difference between an AtMarket and AtClose order for intraday trading is 1 tick... Don't waste your time here - there's absolutely zero practical difference in these orders for intraday.

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

rmcginniss

#6
Thank you very much
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).