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.
Size:
Color:
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.)
Size:
Color:
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
Size:
Color:
Eugene
any chance of help with these two questions please?
Thanks
Size:
Color:
Because your strategy is organized in a way that makes me think so.
Sorry, currently I don't have the time for a rewrite.
Size:
Color:
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
Size:
Color: