Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
having trouble restricting to one trade per session
I am having trouble restricting my program to 1 trade per session. I am using it for an overnight session so a lot of the standard "per day" reserved words don't apply unfortunately. I am very new to EZL so my code is probably a little messy...
It works in restricting it to one entry but once that entry closes it opens another and usually closes it immediately since my exit conditions are still in effect and does that until the end of my session.
Below is the snippets of code that apply directly to this problem.
and
anything you guys can do to help is much appreciated!
Can you help answer these questions from other members on NexusFi?
When I used Tradestation several years ago, I remember they had a function called "Tradestoday" ..
So I would write : if tradestoday = 0 then begin (If I only wanted 1 trade/day)..
It's an easy way to limit the number of trades allowed per day.
Unfortunately, since my session covers multiple days ( 11:00 PM - 9:00 AM ) the tradestoday function doesn't really work for me, I haven't been able to find something similarly simple that works for session that covers multiple days.
I played around with Ninjatrader automated strategies for awhile. The way I would tell it to stop trading is at the beginning of the session I'd set "variable x = 0". Add an "if variable x == 0" argument to your trade premise. As part of the command that sets off the trade, also set variable x = 1. This should stop any other trades from happening until the next session.
Not sure if that's possible in tradestation but it worked for me on Ninjatrader.
Pseudocode example (All additions in Blue/be sure to scroll over to the right to see them all):
It will require an "end", "end" somewhere and can be tricky - I write my codes as individual conditions and one "end" goes after the conditions and the other at the bottom after the execution trigger code. You might have to play with the placement of "end" if it doesn't trigger.
You would have to remove your "StartTime" code to use this or it will conflict.
This should trigger a single trade per day within a 24 hour period.
BlackSwan :Thanks for the help, this is essentially what my code is already attempting to do. The "OneADay" variable is intended to stop the "if" statement from executing. My placement within the code is slightly different than what you suggest here so I'll give it a try in the spot you have it and see how it goes.
Phantomtrader : I really like this way of doing it and will attempt to apply it to my code, I'm trying to think of a way to restrict my trades to the 11:00 PM to 9:00 AM (PST) custom session and still use your 1 trade every 24 hours code.
If the OneADay feature restricts 1 trade to a 24 hour period, you may run into missing a setup in the next session, say if your trade goes off at 12:30am, and your next signal hits the next night at 12:15 it could conceivably skip it since it would still have 15 more minutes on its "clock".
Just speculating. I have no experience with trade station and the little experience I have with Ninja automated was more for backtesting than anything else.
Backstory: I was looking for a mechanical strategy that I could manually trade, so I had a pretty tight session limit (12am - 2am at the time). However, I had to have bars on the chart before the session so that the indicators would work. As I wasn't limiting my trades to 1 a day but configuring to have them not trade outside those hours, that variable did the trick.
That said, good luck in your search. The automated road is a hard one.