Show Last Bar

Hi Guys,
I’m trying to script a show last bar to highlight on a weekly chart when the following occurs:
1, 3+ higher days followed by 1-3 lower day
2. Code MA 53 is above 10 AMA weekly
3. XJO MA53 is above 10 AMA daily
I can get it to work if I don’t limit it to show last. So I guess there is something wrong with the show last script but I can figure it out.

Thanks
Simon

//xjo MA 53 IS ABOVE AMA 10 
V1 = GETDATA(CODE=XJO:ASX, TIMEFRAME=1 Week);
V2 = MA(V1, BARS=53, STYLE=Center, CALC=Close);
V3 = AMA(V1, BARS=10, FASTSC=2, SLOWSC=30);
V2 > V3
//CODE MA 53 IS ABOVE AMA 10
V2 = MA(V1, BARS=53, STYLE=Center, CALC=Close);
V3 = AMA(V1, BARS=10, FASTSC=2, SLOWSC=30);
V2 > V3
//3D 3U SHORT SHOW LAST 1
V1=(OFFSET(BARTYPES().LOWER,OFFSET=5) and OFFSET(BARTYPES().LOWER,OFFSET=4) and
OFFSET(BARTYPES().LOWER,OFFSET=3) and (OFFSET(BARTYPES().Higher,OFFSET=2) OR
OFFSET(BARTYPES().INSIDE,OFFSET=2)) and (OFFSET(BARTYPES().Higher,OFFSET=1) OR
OFFSET(BARTYPES().INSIDE,OFFSET=1)) AND (OFFSET(BARTYPES().Higher,OFFSET=0) OR
OFFSET(BARTYPES().INSIDE,OFFSET=0)) AND HIGH(OFFSET=0)<= HIGH(OFFSET=5) AND
HIGH(OFFSET=1)<= HIGH(OFFSET=5) AND HIGH(OFFSET=2)<= HIGH(OFFSET=5)) OR
(OFFSET(BARTYPES().LOWER,OFFSET=4) and OFFSET(BARTYPES().LOWER,OFFSET=3) AND
OFFSET(BARTYPES().LOWER,OFFSET=2) and (OFFSET(BARTYPES().Higher,OFFSET=1) or
OFFSET(BARTYPES().INSIDE,OFFSET=1) ) and (OFFSET(BARTYPES().Higher,OFFSET=0) or
OFFSET(BARTYPES().INSIDE,OFFSET=0)) AND HIGH(OFFSET=0)<= HIGH(OFFSET=4) AND
HIGH(OFFSET=1)<= HIGH(OFFSET=4)) or (OFFSET(BARTYPES().LOWER,OFFSET=3) and
OFFSET(BARTYPES().LOWER,OFFSET=2) and OFFSET(BARTYPES().LOWER,OFFSET=1) and
(OFFSET(BARTYPES().Higher,OFFSET=0) or OFFSET(BARTYPES().OUTSIDE,OFFSET=0) or
OFFSET(BARTYPES().INSIDE,OFFSET=0)) AND HIGH(OFFSET=0)<= HIGH(OFFSET=3));
V2=ACC(V1);
V3=LAST(V2);
V1==1 and V2 >= V3
//LAST LONG 3DAY CT 53 MA > 10 AMA
(SCRIPT(SCRIPTNAME=CODE MA 53 IS ABOVE AMA 10) and SCRIPT(SCRIPTNAME=A xjo MA 53 IS ABOVE AMA 10 2) AND
SCRIPT(SCRIPTNAME=3U LONG SHOW LAST 1))

[attachment file=“69671”]

TEST-SHOW-BAR.owb (25.5 KB)

Hi,

Individually are the scripts returning the results you are wanting (before they are combined)?

In checking the 3 scripts you posted, no results is returned for the combined option as they do not all occur at the same time. With BHP the 3D 3U occurs on Oct 8, the Code MA53 also triggers on that date, but the XJO MA53 does not.

As the 3D 3U script is setup for the last result only, there’s no other results to check against, so the combined script is 0.

They do work individually.
What I’m trying to achieve is a show bar for the last time all three occurred together.
Is there a way to combine them so they show the last time all three occurred?

Thanks

You need to remove the LAST() reference from the 3D 3U script, so that all historical events are found, not just the last.

//3D 3U SHORT SHOW LAST 1 V1=(OFFSET(BARTYPES().LOWER,OFFSET=5) and OFFSET(BARTYPES().LOWER,OFFSET=4) and OFFSET(BARTYPES().LOWER,OFFSET=3) and (OFFSET(BARTYPES().Higher,OFFSET=2) OR OFFSET(BARTYPES().INSIDE,OFFSET=2)) and (OFFSET(BARTYPES().Higher,OFFSET=1) OR OFFSET(BARTYPES().INSIDE,OFFSET=1)) AND (OFFSET(BARTYPES().Higher,OFFSET=0) OR OFFSET(BARTYPES().INSIDE,OFFSET=0)) AND HIGH(OFFSET=0)<= HIGH(OFFSET=5) AND HIGH(OFFSET=1)<= HIGH(OFFSET=5) AND HIGH(OFFSET=2)<= HIGH(OFFSET=5)) OR (OFFSET(BARTYPES().LOWER,OFFSET=4) and OFFSET(BARTYPES().LOWER,OFFSET=3) AND OFFSET(BARTYPES().LOWER,OFFSET=2) and (OFFSET(BARTYPES().Higher,OFFSET=1) or OFFSET(BARTYPES().INSIDE,OFFSET=1) ) and (OFFSET(BARTYPES().Higher,OFFSET=0) or OFFSET(BARTYPES().INSIDE,OFFSET=0)) AND HIGH(OFFSET=0)<= HIGH(OFFSET=4) AND HIGH(OFFSET=1)<= HIGH(OFFSET=4)) or (OFFSET(BARTYPES().LOWER,OFFSET=3) and OFFSET(BARTYPES().LOWER,OFFSET=2) and OFFSET(BARTYPES().LOWER,OFFSET=1) and (OFFSET(BARTYPES().Higher,OFFSET=0) or OFFSET(BARTYPES().OUTSIDE,OFFSET=0) or OFFSET(BARTYPES().INSIDE,OFFSET=0)) AND HIGH(OFFSET=0)<= HIGH(OFFSET=3)); V1

When that’s done, you can combine the 3 criteria to look for the last time they all happened at once. You can then find the last date this occurred from there using ValueWhen() and BarDate().

V1 = SCRIPT(SCRIPTNAME=3D3U) and SCRIPT(SCRIPTNAME=Code MA 53 IS ABOVE AMA 10) and SCRIPT(SCRIPTNAME=xjo MA 53 IS ABOVE AMA 10);
V2 = BARDATE() ;
V3 = VALUEWHEN(V2,V1) ;
V2 == LAST(V3)

Note, my saved script names may differ to yours.

This will then show the last time all 3 cirteira were met on a chart.

Ex5

Thanks. Works great.

I’m pretty sure, given enough time, I never would have worked that out.