How to Compare Last Trough to Previous Trough
Author: grtrader
Creation Date: 11/4/2014 9:26 AM
profile picture


How in programming, can I refer to the trough before the last trough? For instance, if the last trough is higher than the one before it, Buy. If the last trough is lower than the one before it, do nothing?
profile picture


If you're looking to trade divergences with that, there are dozens of examples. For instance:

FAQ: Can I detect divergences using Wealth-Lab?
ZigZag Class

All of these downloadable strategies illustrate, one way or another, how to compare last trough/peak to penultimate one. Like the FAQ says, there are several approaches:

Mark Crisp 1-2-3 System Long, Short
TASC 2008-07 | Leader Of The MACD Divergence (Siligardos)
RSI Divergence trading system (Long & Short, Timed Exit)
TASC 2008-10 | Asymmetric RSI, ARSI (Vervoort)
S&C 2013-06 | 1-2-3 Wave Count (Vervoort)
ActiveTrader 2008-07 | Wyckoff spring setup

There are more code examples to be found by typing in "trough" in Wealth-Lab's Open Strategy dialog > Search > "Strategy code".
profile picture


Just keep in mind that to create a trough, several [rising] bars will have already passed before you can enter a buy. You're probably not going to see the results that you hope for with this type of system (it's usually better to buy when others are selling), but of course, test everything! :)
profile picture


Thanks for the additional info.

In Mark Crisp 123 System Long, there is a statement that I do not understand:

Please log in to see this code.

I assume that if the SellAtStop if false, it will SellAtLImit. But does it sell at the Stop if it is True?

Is this a shortcut for not using the "else" statement?
profile picture


SellAtStop will execute under all conditions. As you can see in the QuickRef, exit methods return a boolean result. If the result is false, i.e. SellAtStop haven't exited the Position, then SellAtLimit will be processed. Otherwise SellAtLimit will not be evaluated at this bar.
profile picture


profile picture


I don't think there's a way to trade that, though, in live trading.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).