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 -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am a newbie trying to code in EasyLanguage for trade automation in TradeStation for stocks. I would appreciate any help you can offer. First, I must apologize for the poor coding skills, and the long post.
I have worked on the code below for some time now and am having weird results in the back test. For example, entries when I do not expect them, no entries when I do expect them, and some entries as predicted.
The idea behind the code is simple, and most have to do basic algebra, but I feel like I am having some unwanted results because I need to enable IBOG and EasyLanguage has some specific definitions for certain things.
Are my goals possible in EasyLanguage? Do you have any suggestions as to how I can do this?
Here are the challenges:
1- The code should reference Yesterday’s High (Regular Session) for entry and other functions.
2- It must not open a new trade if the target is met (same day, or next day)
3- Since Order automation for a symbol is initiated after market close (EOD data) and are placed based on Close of the Daily Bar (Day 0), I would like the Post market of day 0, following day’s premarket (day 1), and following day’s regular session (day 1 market hours) to be considered as Next day (day 1). So if I pick a stock to run the automation on and initiate automation after market, next day pre market, or during the market hours, it should all reference to day 0.
4- It seems like in order to be able to do extended market trading, I would need to use a smaller time frame than Daily. That produces wild results in my backtesting so I suspect IBOG is the cause of that. I have no idea how to solve this and accomplish the other goals in the code.
5- I can’t seem to reference cash in the account to make sure only a portion of the account balance is available for automated trading. Might only be in backtesting that it fails?
Thank you,
Can you help answer these questions from other members on NexusFi?
If you want a better chance at getting assistance post code as a text attachment. Many, I include myself in that group, are leery of opening code from a internet stranger.
I use Multicharts to compile my EL code and your compiler looks at the code a bit differently. I'm looking at your code and the If-Then-Else-End statements in particular may be treated diffently. And since I do not use Tradestation to create or run my EL code, some of what I mention below may not be available to you -- I bet it is though.
1. Yesterday's RTH high. A couple of ways you could do it but I would go with simply High(1) which should return yesterday's high when the chart is using a => daily <= time frame! You may want to get familiar with using multiple data streams on the same chart -- i.e. insert a new instrument (which can be the same symbol) using the daily time frame and reference yesterday's high in your signal with the code "High(1) data2".
2. Only one trade in the same direction. This is likely a configuration of the strategy -- i.e. in Multicharts I go to "Format signals/Properties/Position limits/Allow up to [x] entry oders in the same direction as the currently held position"
3. Mmmmmm. Not clear what you want to have happen here. Regardless, I'm rather sure you are defining hours that are not pre-defined in the "Instrument Properties" so you will need to create your own set of trading hours. I.e. in EL code you would say "time > 1600 and time < 2000" to define today's post market. To combine yesterday's post market with today's pre market will take four or five lines of code but it can be done.
4. IBOG -- Oh boy...... IBOG is difficult to work with and I can't locate the thread helped me understand how it works, but be aware that backtesting with IBOG can produce odd results. That being said, I get the impression that you could get your strategy working by using a smaller timeframe than "Daily" and forget about using IBOG.
5. Sounds like you are attempting to use a percentage of your current buying power. It could be done. I've never done it so I hesitate to point you in a direction. However, it may be that simply using the properties of the signal might serve -- in Multicharts I use "Format Signal/Properties/" and use "Init Capital" and "Trade size".
I took a look at your code and perhaps you are missing key words for the If-Then-Else-End statements that confuses the compiler. I suspect that Tradestation is seeing a series of commands quite differently that you expect.
A few suggestions:
- Indent your code -- I've included an example
- Create variables for "Value1,2,3 ..." with the same type of descriptive names you have given your inputs.