stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Utility Procedures / Code Snippets
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=166
Page 7 of 7
Author:  simplex [ Sat Nov 11, 2017 5:50 pm ]
Post subject:  Finding the trend

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
Author:  SteveHopwood [ Sun Nov 12, 2017 1:35 am ]
Post subject:  Utility Procedures / Code Snippets

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:
All times are UTC Page 7 of 7