Ichimoku For ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not sure how many people on here use the Ichimoku indicator, but I thought I share this list just in case. Here are a few different Ichimoku scanners for ThinkorSwim.

Ichimoku Cloud Scan by Linus

Code:
# Ichimoku cloud scan

input nTe = 9;  # Tenkan length
input nKi = 26; # Kijun length
input nSp = 52; # SpanB length
def Tenkan = (Highest(high, nTe) + Lowest(low, nTe)) / 2;
def Kijun = (Highest(high, nKi) + Lowest(low, nKi)) / 2;
def SpanA = (Tenkan[nKi] + Kijun[nKi]) / 2;
def SpanB = (Highest(high[nKi], nSp) + Lowest(low[nKi], nSp)) / 2;

# The cloud is made up of SpanA and SpanB, so use Max and Min to scan above and below the cloud.  Only one plot can be active in the scan, so comment out the plot not being used with #.

#plot IsAboveCloud = low > Max(SpanA, SpanB);
plot IsBelowCloud = high < Min(SpanA, SpanB);

A compilation of other related scanners:
Do these scans work for anyone?
 
Here is an "over or under" Cloud that Pete Hahn posted in his forum that I find useful. It would be great if someone could add an inside the cloud status.

Don't look at me. I don't code and have no intentions of learning now. :)

#------ 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.dark_green else if data < 0 then Color.dark_red else Color.dark_gray);
 
Hello everyone, I have modified the Ichimoku cloud to provide long and short entry signals based on the YouTube video
. I back tested few and seems to be working, there are some instances where it provides false signals, I will look into eliminating them. If anyone wants to check it out, here is the code


Code:
# Ichimoku Long and Short entry signals based on Youtube video https://www.youtube.com/watch?v=KE_SAzserLE
# By arv06

# For Long Entry - Tenkan should be above Kijun, Chikou should be above the cloud, price should be above the cloud and cloud in front of 26 candles should be green (bullish)

# For Short Entry - Tenkan should be below Kijun, Chikou should be below the cloud, price should be below the cloud and cloud in front of 26 candles should be red (bearish)

input tenkan_period = 9;
input kijun_period = 26;
input showLabels = yes;
input showAlerts = no;
input showBubbles = yes;
input stopLossToTargetRatio=2;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot SpanA = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot SpanB = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

Tenkan.SetDefaultColor(Color.GREEN);
Tenkan.SetLineWeight(2);

Kijun.SetDefaultColor(Color.RED);
Kijun.SetLineWeight(2);

SpanA.SetDefaultColor(Color.WHITE);
SpanB.SetDefaultColor(Color.YELLOW);

Chikou.SetDefaultColor(Color.MAGENTA);
Chikou.SetLineWeight(2);

DefineGlobalColor("Bullish", Color.DARK_GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(SpanA, SpanB, globalColor("Bullish"), globalColor("Bearish"));

def CloudTop = if SpanA > SpanB then SpanA else SpanB;
def CloudBottom = if SpanA > SpanB then SpanB else SpanA;

AddLabel(showLabels, "Price", if close > CloudTop then Color.GREEN else if close==CloudTop then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses below CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Conversion", if Tenkan > Kijun then Color.GREEN else if Tenkan==Kijun then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && Tenkan crosses above Kijun, concat("Conversion Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Tenkan crosses below Kijun, concat("Conversion Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Chikou", if Chikou[kijun_period] > CloudTop[kijun_period] then Color.GREEN else if Chikou[kijun_period] > CloudTop[kijun_period] then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && Chikou[kijun_period] crosses above CloudTop[kijun_period], concat("Chikou Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Chikou[kijun_period] crosses below CloudTop[kijun_period], concat("Chikou Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Cloud", if SpanA[-kijun_period] > SpanB[-kijun_period] then Color.GREEN else if SpanA[-kijun_period]==SpanB[-kijun_period] then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && SpanA[-kijun_period] crosses above SpanB[-kijun_period], concat("Bullish Cloud @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && SpanA[-kijun_period] crosses below SpanB[-kijun_period], concat("Bearish Cloud @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Trade : " + if close > CloudTop then "Long" else if close < CloudBottom then "Short" else "N/A", if close > CloudTop then Color.GREEN else if close < CloudBottom then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses above CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

plot UpSignal = if (Tenkan > Kijun and close > CloudTop and SpanA[-kijun_period] > SpanB[-kijun_period] and Chikou[kijun_period] crosses above CloudTop[kijun_period])
OR (Tenkan > Kijun and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and close crosses above CloudTop)
OR (close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and Tenkan crosses above Kijun)
OR (Tenkan > Kijun and close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] crosses above SpanB[-kijun_period])
then close else Double.Nan;

plot DownSignal = if (Tenkan < Kijun and close < CloudBottom and SpanA[-kijun_period] < SpanB[-kijun_period] and Chikou[kijun_period] crosses below CloudBottom[kijun_period])
OR (Tenkan < Kijun and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and close crosses below CloudBottom)
OR (close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and Tenkan crosses below Kijun)
OR (Tenkan < Kijun and close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] crosses below SpanB[-kijun_period])
then close else Double.Nan;


UpSignal.SetDefaultColor(Color.WHITE);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

AddChartBubble(showBubbles and UpSignal, close, if UpSignal then "SL: " + CloudBottom + ", T: " + (close + ((close - CloudBottom) * stopLossToTargetRatio)) else "N/A", if UpSignal then Color.LIME else Color.CURRENT);

DownSignal.SetDefaultColor(Color.WHITE);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

AddChartBubble(showBubbles and DownSignal, close, if DownSignal then "SL: " + CloudTop + ", T: " + (close - ((CloudTop - close) * stopLossToTargetRatio)) else  "N/A", if DownSignal then Color.ORANGE else Color.CURRENT);
What is SL and what is T:
 
Not sure how many people on here use the Ichimoku indicator, but I thought I share this list just in case. Here are a few different Ichimoku scanners for ThinkorSwim.

Ichimoku Cloud Scan by Linus

Code:
# Ichimoku cloud scan

input nTe = 9;  # Tenkan length
input nKi = 26; # Kijun length
input nSp = 52; # SpanB length
def Tenkan = (Highest(high, nTe) + Lowest(low, nTe)) / 2;
def Kijun = (Highest(high, nKi) + Lowest(low, nKi)) / 2;
def SpanA = (Tenkan[nKi] + Kijun[nKi]) / 2;
def SpanB = (Highest(high[nKi], nSp) + Lowest(low[nKi], nSp)) / 2;

# The cloud is made up of SpanA and SpanB, so use Max and Min to scan above and below the cloud.  Only one plot can be active in the scan, so comment out the plot not being used with #.

#plot IsAboveCloud = low > Max(SpanA, SpanB);
plot IsBelowCloud = high < Min(SpanA, SpanB);

A compilation of other related scanners:

I've had really trouble with the indicators giving false signals. I'm not sure if im the only one. I'd really just want an indicator that looks at the cloud top broken by candles. I like to look at different timeframes but I often do scalp 5minutes.
 
Hello, I'm looking for a ichimoku kumo cloud break screener for various time frames to keep an eye on the market. I tried the one shared earlier but It doesnt work properly.
 
Last edited:
Hi Ben, How do you read these in terms of bullish vs. bearish?

Code:
# Ichimoku Tenkan/Kijun an early exit warning study_StanL
#the preferred version is version 2 because the arrows accurately show the START of a HA dowtrend
#Now version 2.1

#hint:This is a Ichimoku Tenkan/Kijun an early exit warning study that plots the difference between the tenkan and kijun in histogram format. A YELLOW down warning arrow plots when a Heikin Ashi downtrend starts.
#Background:The difference of the Tenkan and the Kijun indicate the strength of this bullish signal as shown by the histogram above zero values. When this strength difference weakens a downward trend may(often?) start. Heikin Ashi candles are adept at showing trend development. The plotted YELLOW arrows are points to consider exiting even though the entity may be in buillsh territory(i.e. above the cloud). In summary, this is an early warning signal that is productive and calls your attention to it to consider exiting.
#USAGE:When YELLOW down arrows are present, watch the Heikin Ashi style candles to see the extent of the downtrend.(Configure your Heikin Ashi for 'Red Fill' when down. The DMI_Oscillator, MACD and ADX are good complementary studies
#SUMMARY: The histograqm shows  the change in strength of the bullish T/K signal while the YELLOW arrows call your attention to a possible start of a downtrend.

#TOS Title = Ichi_TK_Exit_Warning
# Version date = 5/17/14 by StanL, version 2
# Revision 2.1, added dots at the zero line 5/18/14

declare lower;
input Show_HA_Down = YES;#hint HA_Down:Toggles (ON/OFF) HA-Down-candle arrows showing the start of a HA-Down series. View the HA chart style to see the length of the down series.
#input Show_HA_Up = YES;#hint HA_Up:Toggles (ON/OFF) HA-Up-candle arrows showing the start of a HA-Up series. View the HA chart style to see the length of the up series.
plot Diff = Ichimoku().tenkan - Ichimoku().kijun;
plot ZeroLine = 0;

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
plot HistoLiner = Diff;
HistoLiner.SetDefaultColor(Color.WHITE);
HistoLiner.SetPaintingStrategy(PaintingStrategy.LINE);
HistoLiner.SetLineWeight(1);
#################################################
#def HAopen = (open[1] + close[1]) / 2;
#def HAhigh = Max(high, close[1]);
#def HAlow = Min(low, close[1]);
#def HAclose = (open + high + low + close) / 4;


AddLabel(1, "Plot of Tenkan - Kijun early warning of T/K strength weakening", Color.WHITE);
AddLabel(1, "A YELLOW down arrow plots at the start of a HA downtrend.Watch the HA style chart candles to see the length of the downtrend", Color.YELLOW);

#######################################
### Extracted Mobius Heikin Ashi code #
#######################################
input Begin = 0000;

# Higher Aggregation
def barSeq = if SecondsTillTime(Begin) == 0 and
                   SecondsFromTime(Begin) == 0
                then 0
                else barSeq[1] + 1;
def agg = GetAggregationPeriod();
def BarsPerHour = 60 / (agg / 1000 / 60);
def bar = barSeq;
def barCount = if bar % BarsPerHour == 0
                  then bar
                  else Double.NaN;
def barCountOpen  = if !IsNaN(barCount)
                       then open
                       else barCountOpen[1];
def barCountHigh  = if IsNaN(barCount) and
                          high > barCountHigh[1]
                       then high
                       else if !IsNaN(barCount)
                       then high
                       else barCountHigh[1];
def barCountLow   = if IsNaN(barCount) and
                          low < barCountLow[1]
                       then low
                       else if !IsNaN(barCount)
                       then low
                       else barCountLow[1];
def barCountClose = if !IsNaN(barCount)
                       then close[1]
                       else barCountClose[1];
def HAopen_EV = Round(if HAopen_EV[1] == 0
                      then barCountOpen
                      else (HAopen_EV[1] + barCountClose[1]) / 2 /
                            TickSize(), 0) * TickSize();
def HAclose_EV = Round(if HAopen_EV[1] == 0
                        then OHLC4
                        else (barCountOpen + barCountHigh + barCountLow + HAopen_EV[1])
                              / 4 / TickSize(), 0) * TickSize();
def HAhigh_EV = Round(Max(barCountHigh, barCountClose[1]) /
                      TickSize(), 0) * TickSize();
def HAlow_EV = Round(Min(barCountLow, barCountClose[1]) /
                     TickSize(), 0) * TickSize();
# Color Block For Higher Aggregation
def Size = AbsValue(HAopen_EV - HAopen_EV);
def Block = CompoundValue(1, if HAopen_EV > Block[1] + Size[1]
                                then Block[1] + Size
                                else if HAopen_EV < Block[1] - Size[1]
                                then Block[1] - Size
                                else Block[1] , barCountClose);

plot cond1_EV = Block;
cond1_EV.Hide();
def cond2_EV = if Block != Block[1]
               then Block[1]
               else cond2_EV[1];

plot Block2 = cond2_EV;
Block2.Hide();

#  AssignPriceColor(if HAclose < HAopen
#                   then Color.Red
#                   else Color.Green);

# Trade Management Conditions
def Bcond = CompoundValue(1, if HAclose_EV crosses above HAopen_EV
               then Bcond[1] + 1
               else if HAclose_EV crosses below HAopen_EV
               then 0
               else Bcond[1], 0);

#UP arrow is the start of an HA-up series.  Need to view HA Chart style to see the extent & end
#plot ArrowUp = if Bcond crosses above 0 && Show_HA_Up && Diff < 0 then HistoLiner[0] else Double.NaN;# this line used when up HA arrows are implemented
plot ArrowUp = if Bcond crosses above 0 && Diff < 0 then HistoLiner[0] else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetLineWeight(5);
ArrowUp.SetDefaultColor(Color.YELLOW);

def Scond = CompoundValue(1, if HAclose_EV crosses below HAopen_EV
               then Scond[1] + 1
               else if barCountClose crosses above HAopen_EV
               then 0
               else Scond[1], 0);

#DOWN arrow is the start of an HA-down series. Need to view HA Chart style to see the extent & end
plot ArrowDn = if Scond crosses above 0 && Show_HA_Down && Diff > 0
                 then HistoLiner[0]
                 else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetLineWeight(5);
ArrowDn.SetDefaultColor(Color.YELLOW);

def lineCond = if ArrowUp < ArrowDn
               then 1
               else if ArrowDn > ArrowUp
               then 1
               else -1;

plot line = if IsNaN(ArrowUp)
              then ArrowDn - (TickSize() * 2)
              else ArrowUp + (TickSize() * 2);
line.EnableApproximation();
line.SetLineWeight(2);
line.SetStyle(Curve.SHORT_DASH);
line.AssignValueColor(if lineCond == 1                  
                             then Color.GREEN
                             else if lineCond == -1
                             then Color.RED
                             else Color.WHITE);

######## define dot on zero line when above the cloud ######
def IsAboveCloud = if close > Ichimoku()."Span A" && close > Ichimoku()."Span B" then 1 else 0; # close is above the cloud
def IsBelowCloud = if close < Ichimoku()."Span A" && close < Ichimoku()."Span B" then 1 else 0; # close is below the cloud
Plot AboveCloudDot = if IsAboveCloud then 0 else double.nan;
AboveCloudDot.SetPaintingStrategy(PaintingStrategy.POINTS);
AboveCloudDot.SetLineWeight(3);
AboveCloudDot.SetDefaultColor(Color.GREEN);

Plot BelowCloudDot = if IsBelowCloud then 0 else double.nan;
BelowCloudDot.SetPaintingStrategy(PaintingStrategy.POINTS);
BelowCloudDot.SetLineWeight(3);
BelowCloudDot.SetDefaultColor(Color.RED);

#Define variables used to place a bubble
#========================================
def barNum = BarNumber();
def FirstBar = if barNum == 1 then 1 else 0;
#==========================================
AddChartBubble(FirstBar, 0, "GREEN dot = close IS ABOVE CLOUD\nRED dot = close IS BELOW CLOUD", Color.PINK,no);
#---- End Of Code ---

Hi All! Is there a way to have the arrows plotted directly on the chart without the histogram and having it as a lower indicator? Would prefer the arrows directly over/underneath the candles.

Any help is appreciated!
 
Hey all! Hoping everyone is doing well!

Looking for a little help consolidating two indicators I came across here:

First, Mobius's Adaptation of Ichimoku Strategy (post 11) while a fantastic indicator, lags a bit too much for my style:


# Adaptation of Ichimoku Strategy
# Mobius
# Revised Tenkan and Kijun
# V01.12.2013

input nA = 3;
input nB = 8;

#math
def Tenkan = (Highest(high, nA) + Lowest(low, nA)) / 2;
def Kijun = (Highest(high, nB) + Lowest(low, nB)) / 2;
def "Span A" = (Tenkan[nA] + Kijun[nA]) / 2;
def "Span B" = (Highest(high[nA], nB) + Lowest(low[nA], nB)) / 2;

plot Chikou = Inertia(close[-nA], nB);

# Color Config
#"Span A".SetDefaultColor(Color.PLUM);
#"Span B".SetDefaultColor(Color.YELLOW);
Chikou.SetDefaultColor(Color.WHITE);
DefineGlobalColor("Bullish", Color.YELLOW);
DefineGlobalColor("Bearish", Color.RED);

#AddCloud("Span A", "Span B", GlobalColor("Bullish"), GlobalColor("Bearish"));
##Arrows on Chikou Crossover
# changed from crosses above to >
plot ArrowUp = Chikou crosses above Max("Span A", "Span B");
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUp.SetLineWeight(1);
ArrowUp.SetDefaultColor(Color.WHITE);

# changed from crosses below to <
plot ArrowDn = Chikou crosses below Min("Span A", "Span B");
ArrowDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDn.SetLineWeight(1);
ArrowDn.SetDefaultColor(Color.YELLOW);

However, the Ichimoku Tenkan/Kijun an early exit warning study_StanL captures it in real time and allows me to take a decision much sooner than Mobiu's adaptation:

# Ichimoku Tenkan/Kijun an early exit warning study_StanL
#the preferred version is version 2 because the arrows accurately show the START of a HA dowtrend
#Now version 2.1

#hint:This is a Ichimoku Tenkan/Kijun an early exit warning study that plots the difference between the tenkan and kijun in histogram format. A YELLOW down warning arrow plots when a Heikin Ashi downtrend starts.
#Background:The difference of the Tenkan and the Kijun indicate the strength of this bullish signal as shown by the histogram above zero values. When this strength difference weakens a downward trend may(often?) start. Heikin Ashi candles are adept at showing trend development. The plotted YELLOW arrows are points to consider exiting even though the entity may be in buillsh territory(i.e. above the cloud). In summary, this is an early warning signal that is productive and calls your attention to it to consider exiting.
#USAGE:When YELLOW down arrows are present, watch the Heikin Ashi style candles to see the extent of the downtrend.(Configure your Heikin Ashi for 'Red Fill' when down. The DMI_Oscillator, MACD and ADX are good complementary studies
#SUMMARY: The histograqm shows the change in strength of the bullish T/K signal while the YELLOW arrows call your attention to a possible start of a downtrend.

#TOS Title = Ichi_TK_Exit_Warning
# Version date = 5/17/14 by StanL, version 2
# Revision 2.1, added dots at the zero line 5/18/14

declare lower;
input Show_HA_Down = YES;#hint HA_Down:Toggles (ON/OFF) HA-Down-candle arrows showing the start of a HA-Down series. View the HA chart style to see the length of the down series.
#input Show_HA_Up = YES;#hint HA_Up:Toggles (ON/OFF) HA-Up-candle arrows showing the start of a HA-Up series. View the HA chart style to see the length of the up series.
plot Diff = Ichimoku().tenkan - Ichimoku().kijun;
plot ZeroLine = 0;

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
plot HistoLiner = Diff;
HistoLiner.SetDefaultColor(Color.WHITE);
HistoLiner.SetPaintingStrategy(PaintingStrategy.LINE);
HistoLiner.SetLineWeight(1);
#################################################
#def HAopen = (open[1] + close[1]) / 2;
#def HAhigh = Max(high, close[1]);
#def HAlow = Min(low, close[1]);
#def HAclose = (open + high + low + close) / 4;


AddLabel(1, "Plot of Tenkan - Kijun early warning of T/K strength weakening", Color.WHITE);
AddLabel(1, "A YELLOW down arrow plots at the start of a HA downtrend.Watch the HA style chart candles to see the length of the downtrend", Color.YELLOW);

#######################################
### Extracted Mobius Heikin Ashi code #
#######################################
input Begin = 0000;

# Higher Aggregation
def barSeq = if SecondsTillTime(Begin) == 0 and
SecondsFromTime(Begin) == 0
then 0
else barSeq[1] + 1;
def agg = GetAggregationPeriod();
def BarsPerHour = 60 / (agg / 1000 / 60);
def bar = barSeq;
def barCount = if bar % BarsPerHour == 0
then bar
else Double.NaN;
def barCountOpen = if !IsNaN(barCount)
then open
else barCountOpen[1];
def barCountHigh = if IsNaN(barCount) and
high > barCountHigh[1]
then high
else if !IsNaN(barCount)
then high
else barCountHigh[1];
def barCountLow = if IsNaN(barCount) and
low < barCountLow[1]
then low
else if !IsNaN(barCount)
then low
else barCountLow[1];
def barCountClose = if !IsNaN(barCount)
then close[1]
else barCountClose[1];
def HAopen_EV = Round(if HAopen_EV[1] == 0
then barCountOpen
else (HAopen_EV[1] + barCountClose[1]) / 2 /
TickSize(), 0) * TickSize();
def HAclose_EV = Round(if HAopen_EV[1] == 0
then OHLC4
else (barCountOpen + barCountHigh + barCountLow + HAopen_EV[1])
/ 4 / TickSize(), 0) * TickSize();
def HAhigh_EV = Round(Max(barCountHigh, barCountClose[1]) /
TickSize(), 0) * TickSize();
def HAlow_EV = Round(Min(barCountLow, barCountClose[1]) /
TickSize(), 0) * TickSize();
# Color Block For Higher Aggregation
def Size = AbsValue(HAopen_EV - HAopen_EV);
def Block = CompoundValue(1, if HAopen_EV > Block[1] + Size[1]
then Block[1] + Size
else if HAopen_EV < Block[1] - Size[1]
then Block[1] - Size
else Block[1] , barCountClose);

plot cond1_EV = Block;
cond1_EV.Hide();
def cond2_EV = if Block != Block[1]
then Block[1]
else cond2_EV[1];

plot Block2 = cond2_EV;
Block2.Hide();

# AssignPriceColor(if HAclose < HAopen
# then Color.Red
# else Color.Green);

# Trade Management Conditions
def Bcond = CompoundValue(1, if HAclose_EV crosses above HAopen_EV
then Bcond[1] + 1
else if HAclose_EV crosses below HAopen_EV
then 0
else Bcond[1], 0);

#UP arrow is the start of an HA-up series. Need to view HA Chart style to see the extent & end
#plot ArrowUp = if Bcond crosses above 0 && Show_HA_Up && Diff < 0 then HistoLiner[0] else Double.NaN;# this line used when up HA arrows are implemented
plot ArrowUp = if Bcond crosses above 0 && Diff < 0 then HistoLiner[0] else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetLineWeight(5);
ArrowUp.SetDefaultColor(Color.YELLOW);

def Scond = CompoundValue(1, if HAclose_EV crosses below HAopen_EV
then Scond[1] + 1
else if barCountClose crosses above HAopen_EV
then 0
else Scond[1], 0);

#DOWN arrow is the start of an HA-down series. Need to view HA Chart style to see the extent & end
plot ArrowDn = if Scond crosses above 0 && Show_HA_Down && Diff > 0
then HistoLiner[0]
else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetLineWeight(5);
ArrowDn.SetDefaultColor(Color.YELLOW);

def lineCond = if ArrowUp < ArrowDn
then 1
else if ArrowDn > ArrowUp
then 1
else -1;

plot line = if IsNaN(ArrowUp)
then ArrowDn - (TickSize() * 2)
else ArrowUp + (TickSize() * 2);
line.EnableApproximation();
line.SetLineWeight(2);
line.SetStyle(Curve.SHORT_DASH);
line.AssignValueColor(if lineCond == 1
then Color.GREEN
else if lineCond == -1
then Color.RED
else Color.WHITE);

######## define dot on zero line when above the cloud ######
def IsAboveCloud = if close > Ichimoku()."Span A" && close > Ichimoku()."Span B" then 1 else 0; # close is above the cloud
def IsBelowCloud = if close < Ichimoku()."Span A" && close < Ichimoku()."Span B" then 1 else 0; # close is below the cloud
Plot AboveCloudDot = if IsAboveCloud then 0 else double.nan;
AboveCloudDot.SetPaintingStrategy(PaintingStrategy.POINTS);
AboveCloudDot.SetLineWeight(3);
AboveCloudDot.SetDefaultColor(Color.GREEN);

Plot BelowCloudDot = if IsBelowCloud then 0 else double.nan;
BelowCloudDot.SetPaintingStrategy(PaintingStrategy.POINTS);
BelowCloudDot.SetLineWeight(3);
BelowCloudDot.SetDefaultColor(Color.RED);

#Define variables used to place a bubble
#========================================
def barNum = BarNumber();
def FirstBar = if barNum == 1 then 1 else 0;
#==========================================
AddChartBubble(FirstBar, 0, "GREEN dot = close IS ABOVE CLOUD\nRED dot = close IS BELOW CLOUD", Color.PINK,no);
#---- End Of Code ---

My request is, how would I go about replacing the ARROWUP and ARROWDN plots in Mobius's Adaptation with the ARROWUP & ARROWDN plots in the Early Exit Warning Study such that it plots directly on the chart (not as a lower indicator)? I've been banging my head on my desk all weekend trying to figure it out.

Any help is much appreciated. Thank you!!!!

Eric
 
Here is an "over or under" Cloud that Pete Hahn posted in his forum that I find useful. It would be great if someone could add an inside the cloud status.

Don't look at me. I don't code and have no intentions of learning now. :)

#------ 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.dark_green else if data < 0 then Color.dark_red else Color.dark_gray);
How can I make it over or under price for chikou span instead of over and under cloud for chikou span
 
Hello everyone, I have modified the Ichimoku cloud to provide long and short entry signals based on the YouTube video
. I back tested few and seems to be working, there are some instances where it provides false signals, I will look into eliminating them. If anyone wants to check it out, here is the code


Code:
# Ichimoku Long and Short entry signals based on Youtube video https://www.youtube.com/watch?v=KE_SAzserLE
# By arv06

# For Long Entry - Tenkan should be above Kijun, Chikou should be above the cloud, price should be above the cloud and cloud in front of 26 candles should be green (bullish)

# For Short Entry - Tenkan should be below Kijun, Chikou should be below the cloud, price should be below the cloud and cloud in front of 26 candles should be red (bearish)

input tenkan_period = 9;
input kijun_period = 26;
input showLabels = yes;
input showAlerts = no;
input showBubbles = yes;
input stopLossToTargetRatio=2;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot SpanA = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot SpanB = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

Tenkan.SetDefaultColor(Color.GREEN);
Tenkan.SetLineWeight(2);

Kijun.SetDefaultColor(Color.RED);
Kijun.SetLineWeight(2);

SpanA.SetDefaultColor(Color.WHITE);
SpanB.SetDefaultColor(Color.YELLOW);

Chikou.SetDefaultColor(Color.MAGENTA);
Chikou.SetLineWeight(2);

DefineGlobalColor("Bullish", Color.DARK_GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(SpanA, SpanB, globalColor("Bullish"), globalColor("Bearish"));

def CloudTop = if SpanA > SpanB then SpanA else SpanB;
def CloudBottom = if SpanA > SpanB then SpanB else SpanA;

AddLabel(showLabels, "Price", if close > CloudTop then Color.GREEN else if close==CloudTop then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses below CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Conversion", if Tenkan > Kijun then Color.GREEN else if Tenkan==Kijun then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && Tenkan crosses above Kijun, concat("Conversion Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Tenkan crosses below Kijun, concat("Conversion Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Chikou", if Chikou[kijun_period] > CloudTop[kijun_period] then Color.GREEN else if Chikou[kijun_period] > CloudTop[kijun_period] then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && Chikou[kijun_period] crosses above CloudTop[kijun_period], concat("Chikou Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Chikou[kijun_period] crosses below CloudTop[kijun_period], concat("Chikou Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Cloud", if SpanA[-kijun_period] > SpanB[-kijun_period] then Color.GREEN else if SpanA[-kijun_period]==SpanB[-kijun_period] then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && SpanA[-kijun_period] crosses above SpanB[-kijun_period], concat("Bullish Cloud @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && SpanA[-kijun_period] crosses below SpanB[-kijun_period], concat("Bearish Cloud @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Trade : " + if close > CloudTop then "Long" else if close < CloudBottom then "Short" else "N/A", if close > CloudTop then Color.GREEN else if close < CloudBottom then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses above CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

plot UpSignal = if (Tenkan > Kijun and close > CloudTop and SpanA[-kijun_period] > SpanB[-kijun_period] and Chikou[kijun_period] crosses above CloudTop[kijun_period])
OR (Tenkan > Kijun and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and close crosses above CloudTop)
OR (close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and Tenkan crosses above Kijun)
OR (Tenkan > Kijun and close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] crosses above SpanB[-kijun_period])
then close else Double.Nan;

plot DownSignal = if (Tenkan < Kijun and close < CloudBottom and SpanA[-kijun_period] < SpanB[-kijun_period] and Chikou[kijun_period] crosses below CloudBottom[kijun_period])
OR (Tenkan < Kijun and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and close crosses below CloudBottom)
OR (close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and Tenkan crosses below Kijun)
OR (Tenkan < Kijun and close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] crosses below SpanB[-kijun_period])
then close else Double.Nan;


UpSignal.SetDefaultColor(Color.WHITE);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

AddChartBubble(showBubbles and UpSignal, close, if UpSignal then "SL: " + CloudBottom + ", T: " + (close + ((close - CloudBottom) * stopLossToTargetRatio)) else "N/A", if UpSignal then Color.LIME else Color.CURRENT);

DownSignal.SetDefaultColor(Color.WHITE);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

AddChartBubble(showBubbles and DownSignal, close, if DownSignal then "SL: " + CloudTop + ", T: " + (close - ((CloudTop - close) * stopLossToTargetRatio)) else  "N/A", if DownSignal then Color.ORANGE else Color.CURRENT);
I have been using this strategy for a bit and would like to know if there is a way to make a scanner for it? It would make life a little bit easier lol
 
How can I make it over or under price for chikou span instead of over and under cloud for chikou span
I have looked into this and can't get chikou to return a value really strange. Chikou is nothing more then price 26 candles back. So I would look for a comparison price 26 candles back to Chikou. I can get price 26 candles back but nothing for Chikou. It shows N/A in my Label.
It would be a more textbook approach for sure.
 
Last edited by a moderator:
Hello. I found these 2 scans in a thread from back in 2019 but they actually date back to 2015 and 2014. What caught my attention was what they were named - exactly what I was looking for, candles above the cloud.

When I load them I get a error or I am unable to run them. Can anyone help me with editing them so they can run?

Thanks in advance!!!!
Jason

https://tos.mx/GSfZab – Ichimoku 3 candles above the cloud
Ruby:
##### Inside The Cloud Scanner
##### Made By Leonard
##### Version 2
##### 10/12/2014
declare lower;

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 > span_b;
DEF VMAX_1= Span_b > Span_a;
def cloud =  price[2] crosses above span_a && price[1] > span_a && price > Span_A;
def cloud_1 = price[2] crosses above span_b[1] && price > span_b && price > span_B;
PLOT VBI =if vmax and cloud then 1 else if vmax_1 and cloud_1 then -1 else 0 ;
 
AssignBackgroundColor(if vmax then color.dark_green else if vmax_1 then color.dark_red else color.current);

AddLabel(yes, if vmax and cloud then "BA: " + Round(cloud, 2) else if vmax_1 and cloud_1 then "BA: " +round(cloud_1,2) else "" , color.current);

& https://tos.mx/HnAeox – Ichimoku 3 candles above the cloud.
Ruby:
##### Inside The Cloud Scanner
##### Made By Leonard
##### Version 2
##### 10/12/2014
declare lower;

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 > span_b;
DEF VMAX_1= Span_b > Span_a;
def cloud =  price[1] crosses above span_a && price > span_a;
def cloud_1 = price[1] crosses above span_b && price > span_b;
PLOT VBI =if vmax and cloud then 1 else if vmax_1 and cloud_1 then -1 else 0 ;
 
AssignBackgroundColor(if vmax then color.dark_green else if vmax_1 then color.dark_red else color.current);

AddLabel(yes, if vmax and cloud then "BA: " + Round(cloud, 2) else if vmax_1 and cloud_1 then "BA: " +round(cloud_1,2) else "" , color.current);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
353 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top