Ichimoku Candles - with Chikou - buy sell signals - thinkscript thinkorswim tos

# testing candle red/green/ gray ichimoku candles
#Price above cloud chikou above cloud green
#Price Below cloud chikou above cloud red
#Price or chikou inside cloud gray
#still in the works, however may be final feel free to adjust
declare upper;

input price = close;
input tenkan_period = 9;
input kijun_period = 26;

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 Chikou = close[-kijun_period];

DEF VMAX = Span_a[26] > span_b[26];
DEF VMAX_1= Span_b[26] > Span_a[26];
def cloud =  chikou[26] > span_A[26] and span_B [26] ;
def cloud_1 = chikou[26] < span_B[26] and span_A[26] ;


AssignPriceColor( if  cloud and price > span_a and span_b[26]  then (color.green) else if cloud_1  and price < span_b  and span_a[26]    then (color.red) else (color.gray) );