Utility Procedures / Code Snippets

Post Reply
User avatar
simplex
Trader
Posts: 124
Joined: Thu Feb 07, 2013 5:21 pm
Location: An insignificant village close to an insignificant former capital at the Rhine River.

Finding the trend

Post by simplex »

DigitalCrypto » 11 Nov 2017, 13:16 wrote:Here's a function I wrote to determine a market trend using a higher timeframe without relying on any indicators.
Nice idea, thanks! When reviewing your code, I did not understand the redundant logic:

First you check for the latest trend condition in those two while loops for a maximum depth of 20 bars.

Then you take the result of that first check and check the same thing again, just for the latest bar. Commenting this last check out should not make any difference, right?

Or did I miss something ... ?

Regards, simplex
If you can't explain it simply, you don't understand it well enough. (Albert Einstein)
It appears that the Weighted Moving Average was invented by a trader who did not have a firm grasp of filter theory in hopes of reducing lag. (John F. Ehlers)
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Utility Procedures / Code Snippets

Post by SteveHopwood »

You need to set set TrendUp and TrendDown to false at the beginning of void FindTrend() and not in OnInt()

Otherwise once void FindTrend() sets a trend, it will never be changed.

Don't feel bad about this. Maximilion caught me out doing the same thingy in a different context only last week, and I have been doing this stuff for years.

:xm:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. [email protected] is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Coders Hangout”