// DEFPARAM
DEFPARAM CumulateOrders = False
DEFPARAM PreLoadBars = 1000
// Ichimoku code
Tenkan = (highest[9](high)+lowest[9](low))/2
Kijun = (highest[26](high)+lowest[26](low))/2
SenkouSpanA = (Tenkan+Kijun)/2
SenkouSpanB = (highest[52](high)+lowest[52](low))/2
CurrentSenkouSpanA = min(SenkouSpanA[26],SenkouSpanB[26])
CurrentSenkouSpanB = max(SenkouSpanA[26],SenkouSpanB[26])
Chinkou = close
// Position size
PSize = 1
// Opening long
// Conditions
olc1 = close > CurrentSenkouSpanA
olc2 = close > CurrentSenkouSpanB
olc3 = close > Tenkan
olc4 = close > Kijun
olc5 = Chinkou > close[26]
olc6 = Chinkou > Tenkan[26]
olc7 = Chinkou > Kijun[26]
olc8 = Chinkou CROSSES OVER MAX(CurrentSenkouSpanA[26],CurrenttSenkouSpanB[26])
// Opening Long
IF olc1 AND olc2 AND olc3 AND olc4 AND olc5 AND olc6 AND olc7 AND olc8 THEN
BUY Psize CONTRACT AT MARKET
ENDIF