NexusFi: Find Your Edge


Home Menu

 





Moving Average Bias


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,342 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Moving Average Bias

  #1 (permalink)
Jsper32
San francisco
 
Posts: 2 since Apr 2020
Thanks Given: 2
Thanks Received: 0

Hello-

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!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #2 (permalink)
 semiopen 
hillsborough nj
 
Experience: Advanced
Platform: Tradestation/Excel
Broker: TradeStation
Trading: emicro
Posts: 98 since Sep 2018
Thanks Given: 18
Thanks Received: 46

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);

variables:
Ma1( 0 ), Ma2(0), Ma3(0), Ma4(0);

Ma1 = AverageFC( Price, Ma1Len ) ;
Ma2 = AverageFC( Price, Ma2Len ) ;
Ma3 = AverageFC( Price, Ma3Len ) ;
Ma4 = AverageFC( Price, Ma4Len ) ;

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.

Reply With Quote
Thanked by:
  #3 (permalink)
Jsper32
San francisco
 
Posts: 2 since Apr 2020
Thanks Given: 2
Thanks Received: 0


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.

Reply With Quote
  #4 (permalink)
 HarleyDS 
Chanute, KS United States
 
Experience: Intermediate
Platform: TradeStation
Trading: Options
Posts: 3 since Mar 2015
Thanks Given: 1
Thanks Received: 1

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?!?

Reply With Quote
Thanked by:
  #5 (permalink)
 semiopen 
hillsborough nj
 
Experience: Advanced
Platform: Tradestation/Excel
Broker: TradeStation
Trading: emicro
Posts: 98 since Sep 2018
Thanks Given: 18
Thanks Received: 46

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.

Reply With Quote




Last Updated on May 9, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts