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)
I am new to programming. I've been tinkering around on Tradestation and easylanguage. I'm wondering if anyone can help me code a "bias indicator"
So instead of entering a trade when the moving averages cross, it would be a bias filter to only enter a trade if one moving average is above the other.
For example, let's say I want to enter a trade when the 9 MA crosses over the 21MA but I only want to take the trade if the 10 MA is over the 50 MA.
So it might read like "enter a long position when the 9 MA crosses over the 21 MA but only if the 10 MA is currently above the 50 MA"
I hope my question is clear. Thanks!
Also if anyone feels like answering more emails about Easylanguage and wants to serve as kind of a mentor, I'd be much obliged!
Can you help answer these questions from other members on NexusFi?
This is not an appropriate strategy with the inputs you supplied, but here is my easylanguage interpretation. I put in a sell if the condition you describe is no longer true. It has made 8 trades on @ES since 7/23/18 and broke about even.
inputs:
Price( Close ),
Ma1Len(9), Ma2Len(21), Ma3Len(10), Ma4Len(50);
if Ma1 > Ma2 and Ma3 > Ma4 then
Buy ( !( "MACrossLE" ) ) next bar at market;
if Ma1 < Ma2 or Ma3 < Ma4 then
Sell ( !( "MACrossLX" ) ) next bar at market;
I've written some moving average articles on seekingalpha and have posted links in some threads on here.
Easylanguage isn't the best language to specialize in, especially if you are new and serious (I can tell you are new). You will not be able to build something solid enough to automate even with considerable experience, and EasyLanguage doesn't have much of a future. Probably better to learn Python, personally I use Excel VBA.
Feel free to message me if you have questions, but posting to the forums is useful.
Ok cool. I will definitely take that into advisement.
So I tried to do a little more research and was wondering if I could do a "if *** then begin"
I suppose the code might look like:
"If 10MA is above the 50MA then begin...
If 9 MA crosses over 21 MA then buy at market"
end;
I haven't really tried it yet. And yes I am very new. I don't even really understand the difference between inputs and variables and how they work together.
Simple moving averages are hampered by very slow response.
You might consider purchasing a book Cycle Analytics for Traders authored by John F. Ehlers.
John's book comes with downloadable software all in EasyLanguage code. (How's that for a lucky break!)
The supersmoother and the decycler have both been very beneficial for me and they are included in the downloadable code.
John's code will also give you good examples to help you with learning EasyLanguage.
Indicator plotting is a trade-off between fast response and smoothness. At one extreme the indicator is very smooth but also very slow response.
So slow in fact that it is too late to be of any value. At the over extreme the indicator is as fast as the price and therefore has no smoothing.
(Just as well watch the price itself)
John's indicators achieve a very good response time while simultaneously giving a smooth plot.
Also, rather than crossovers, you might consider something like the following where X is the output value from one of the indicators.
If X > X[1] Then
Plot1(X, "X", Green, 0, 1)
Else
Plot1(x, "X", Red, 0, 1);
This will give a much quicker response rather than waiting for averages to crossover. In this example the color change would equate to a crossover.
In addition, if you are looking for more experience and EasyLanguage examples, check out Markplex.com.
Martyn has tutorial videos and code examples which are a great way to get EasyLanguage useage exposure.
Hope you find this helpful.
Good luck!
Harley
P.S. Have a bottle of aspirin handy when reading John's book. It's a real brain twister.
Each time I read his book it says more.... I just don't understand how it does that?!?
Inputs are values you supply to the strategy. You can change the inputs when you put the strategy on a chart, for example change 9 to 13 and 21 to 31. Variables are values calculated by the algorithm.
Harley is right about issues with moving averages as trading signals, but at the end of the day, traders randomly enter positions and exit at some point; hopefully for a profit.
The If Then Else structure you suggest might work, I don't think it is better than my example, if it works it should be equivalent. Ordinarily the 9 and 10 day will cross above longer term averages simultaneously, so if the 9 day crosses the 21 day the 10 will too. Perhaps you want to look at the previous day's 10 day 50 day position, but more likely you are confused about what you want to happen.
Price above moving average is simpler than doing crossovers and play OK. Good money can be made buying one day before a buy signal and sell at least one day before the sell signal. It is hard to make back the profits foregone by buying and selling a day too late.