Script Help: Close above Ichimoku cloud

I am trying to create a watchlist with specific true/false metrics.

I can’t figure out how to script a close above the Ichimoku cloud.

I am using CLOSE() > ICHIMOKUCLOUD(DEFAULT=CloudBandUpper);

and I tried: CLOSE() > ICHIMOKUCLOUD(DEFAULT=SenkouSpanA); and CLOSE() > ICHIMOKUCLOUD(DEFAULT=SenkouSpanB);

The True/False result doesn’t match the actual chart. Not sure what I am doing wrong.

Thanks for any help!

Hi,

The Ichimoku Cloud plots past the last bar. The script is referencing the last value of the tool, which in your screenshot the Close is below, causing the criteria to fail.

To achieve the result you are after you need to lock the Ichimoku Clouds function to the bars, so it does not go into the future.

The best way to do that is using the BARINDEX() function as per the following…

//Set Cloud Plot
V1 = ICHIMOKUCLOUD().CloudBandUpper;
//Lock Plot to Bar
V2 = BARINDEX() > 0;
V3 = IF(V2 == 1,V1,0);
//Is Close > Plot
CLOSE() > V3

Once done, the expected results are returned.