Ichimoku Cloud script

Hello, I am trying to write a script for daily and weekly bar opens and closes above the Ichimoku cloud. I asked the ScripterBot, and this is what I got, which shows no results on the chart. I am not sure if the setting has to be plotted into the script in order to see the result on the showbar option.

Thanks,

Mo

// Calculate Ichimoku Cloud components
IchimokuCloud = ICHIMOKU(); // Get Ichimoku Cloud values
TenkanSen = IchimokuCloud.Tenkan; // Tenkan-sen line
KijunSen = IchimokuCloud.Kijun; // Kijun-sen line
SenkouSpanA = IchimokuCloud.SenkouA; // Senkou Span A
SenkouSpanB = IchimokuCloud.SenkouB; // Senkou Span B

// Check if the daily bar opens and closes above the Ichimoku cloud
OpenAboveCloud = Open() > Max(SenkouSpanA, SenkouSpanB); // Open above the cloud
CloseAboveCloud = Close() > Max(SenkouSpanA, SenkouSpanB); // Close above the cloud

// Combine conditions
DailyBarAboveCloud = OpenAboveCloud and CloseAboveCloud;

// Output the condition
DailyBarAboveCloud;

Hi Mo,

The scripterbot is still learning and hasn’t been asked about Ichimoku before so we’ll get it retrained on the syntax. However, it’s tricky because the script function uses the current value of the tool - which is offset by 26 bars in to the future - so we have to take that into account in the formula.

For example, this chart of AAPL is showing as false for close above the cloud because the close (243.85) is below the current value of the SenkouSpanA (247.94), even though it appears above the cloud on the chart:

To fix, use [26] to offset the span accordingly, so for open and close above the cloud use this:

//Get SpanA value and offset by 26 bars;
SpanA = ICHIMOKUCLOUD(DEFAULT=SenkouSpanA)[26];
OPEN()>SpanA and CLOSE()>SpanA