Thanks for providing that screenshot, it really helps explain what you are looking for. We can easily do the color scheme based on position of close above, below or inside the cloud. The other items such as trend direction and chikou direction would require some clearer specifications. I have no idea how those items are defined. Even your request to indicate from which direction the price is entering the cloud. Price enters the cloud on one bar. Once that bar has passed, prices can remain in the cloud for an extended period of time. Does it still matter which direction it entered from after it’s been in the cloud for 20 bars?
So I’ve taken care of the elements that are clearly specified. The other items will remain uncompleted until a clearer specification can be provided. It’s up to our viewers to provide those specifications. Don’t forget to up-vote any questions that best solve your question!
#------ Inputs for Ichimoku plots
input tenkan_period = 9;
input kijun_period = 26;
#----------- Section for plotting the Ichimoku
def Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
def Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
def "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
def "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
def closeAboveCloud = close > "Span A" and close > "Span B";
def closeBelowCloud = close < "Span B" and close < "Span B";
def closeInsideCloud = (close > "Span A" and close < "Span B") or (close < "Span A" and close > "Span B");
plot data = if closeAboveCloud then 1 else if closeBelowCloud then -1 else if closeInsideCloud then 0 else 0;
AssignBackgroundColor(if data > 0 then Color.BLUE else if data < 0 then Color.ORANGE else Color.BLACK);