Exiting when divergence pattern erodes
Author: topcat77
Creation Date: 8/12/2009 11:20 PM
profile picture

topcat77

#1
In this Divergence program I want to insert an exit condition that will stop out when the divergence condition has broken down: Exit if rsi[bar] crosses under (rsi[prevLowBar]less some amount). preLowBar is used in the script to identify the previous low within the specified lookback period when identifying the initial divergence signal


So in the exit section I changed
QUOTE:
if (CrossOver(bar, rsi, 55))

to
QUOTE:
if (CrossOver(bar, rsi, 55)|| CrossUnder(bar,rsi,(rsi[prevLowBar]-1)))


and I got an error message: "The name 'prevLowBar' does not exist in the current context." I can see why this is - prevLowBar is defined further down the script but I don't know how to fix that. (Also I'm not sure that I've written the new Exit condition properly

Help much appreciated


CODE:
Please log in to see this code.

profile picture

Eugene

#2
I guess you mean to say (rsi[prevLowBar-1]) instead of (rsi[prevLowBar]-1).

(That alone, however, wouldn't help as you'll need to rewrite a good deal of logic.)
profile picture

topcat77

#3
QUOTE:
[/QUOTE]
I guess you mean to say (rsi[prevLowBar-1]) instead of (rsi[prevLowBar]-1).

Just to confirm - the exit is a stop at 1 rsi less than that of the preLowBar.
( not the rsi of the bar before the preLowBar). Does " (rsi[prevLowBar-1])" do
that?

[QUOTE](That alone, however, wouldn't help as you'll need to rewrite a good deal of logic.)


Well, all I'm looking for is to insert "prevLowBar" into the exit statement;
why would that require an extensive rewrite of the logic? How could I do this ?

Thanks

profile picture

topcat77

#4
Eugene
any chance of help with these two questions please?
Thanks
profile picture

Eugene

#5
Because your strategy is organized in a way that makes me think so.

Sorry, currently I don't have the time for a rewrite.
profile picture

topcat77

#6

I've used ..crossUnder rsi[signalBar]- x .. as a rough surrogate
to define the end of a divergence pattern. It's not as effective
(or accurate) as using prevLowBar but it has the same intent.

If, at some point, you find the time to amend the script to show how
to use prevLowBar that would be very useful.

This would also provide a generic way to identify the collapse of a
divergence pattern

Thank You
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).