Trailing Stop using Last Down Bar

Hi,

Can anybody please help.

I am trying to script a trailing Stop Loss which uses the last Down Bar. As per the attached diagram.

I have used LOW() <= LAST(BARTYPES().Lower Also tried other variations like CrossesUnder and Crosses.

However the “LAST()” function does not work as I think!

Does anyone know what does?

Also would like to know how to correctly use LAST() function.

Thanks in anticipation,

Lester

CT-Stop-Loss-Picture.png

Hi Lester,

LAST() plots the latest value of the tool or price. See here for examples:

https://help.optuma.com/kb/faq.php?id=1091

To get the value of the last low of a lower bar (including an outside bar) use the VALUEWHEN() function:

V1 = BARTYPES().Lower or BARTYPES().Outside;
VALUEWHEN(LOW(),V1)

So the stop formula would be when the low value of the lower/outside bar is lower than the previous:

// Identify lower & outside bars;
V1 = BARTYPES().Lower or BARTYPES().Outside;
//Get the low value when V1 is true
V2=VALUEWHEN(LOW(),V1);
//Signal when low is lower
V2 IsDown

The blue line is the low value and the red Show Bars are when they are lower:

Capture