ATR Ichimoku For ThinkOrSwim

Micheal

New member
Ruby:
# ATR Ichimoku
# v1.0 - barbaros
# v1.1 - barbaros - candle colors

input tenkan_period = 9;
input tenkan_mult = 2.0;
input kijun_period = 26;
input kijun_mult = 4.0;
input spanB_period = 52;
input spanB_mult = 6.0;
input showCloud = yes;
input colorBars = yes;

DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
script _avg {
input src = close;
input length = 9;
input mult = 2;

def _atr = ATR(length) * mult;
def up = hl2 + _atr;
def dn = hl2 - _atr;
def upper = if src[1] < upper[1] then Min(up, upper[1]) else up;
def lower = if src[1] > lower[1] then Max(dn, lower[1]) else dn;
def os = if src > upper then 1 else if src < lower then 0 else os[1];
def spt = if os == 1 then lower else upper;
def _max = if src crosses spt then Max(src, _max[1]) else if os == 1 then Max(src, _max[1]) else spt;
def _min = if src crosses spt then Min(src, _min[1]) else if os == 0 then Min(src, _min[1]) else spt;
plot return = (_max + _min) / 2;
}

plot Tenkan = _avg(close, tenkan_period, tenkan_mult);
plot Kijun = _avg(close, kijun_period, kijun_mult);
plot TKCrossUp = Tenkan crosses above Kijun;
plot TKCrossDown = Tenkan crosses below Kijun;

def Direction = if TKCrossUp then 1 else if TKCrossDown then -1 else Direction[1];
def senkouA = (kijun + tenkan) / 2;
def senkouB = _avg(close,spanB_period,spanB_mult);
Tenkan.SetDefaultColor(Color.CYAN);
Tenkan.SetLineWeight(2);
Tenkan.HideBubble();
Tenkan.HideTitle();

Kijun.SetDefaultColor(Color.MAGENTA);
Kijun.SetLineWeight(2);
Kijun.HideBubble();
Kijun.HideTitle();

TKCrossUp.SetDefaultColor(Color.CYAN);
TKCrossUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TKCrossUp.SetLineWeight(3);
TKCrossUp.HideBubble();
TKCrossUp.HideTitle();

TKCrossDown.SetDefaultColor(Color.MAGENTA);
TKCrossDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TKCrossDown.SetLineWeight(3);
TKCrossDown.HideBubble();
TKCrossDown.HideTitle();

AddCloud(if showCloud then senkouA[spanB_period] else Double.NaN, if showCloud then senkouB[spanB_period] else Double.NaN, GlobalColor("Bullish"), GlobalColor("Bearish"));

AssignPriceColor(if !colorBars then Color.CURRENT
else if Direction == 1 then GlobalColor("Bullish")
else if Direction == -1 then GlobalColor("Bearish")
else Color.GRAY);
 
Last edited by a moderator:

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

Ruby:
# ATR Ichimoku
# v1.0 - barbaros
# v1.1 - barbaros - candle colors

input tenkan_period = 9;
input tenkan_mult = 2.0;
input kijun_period = 26;
input kijun_mult = 4.0;
input spanB_period = 52;
input spanB_mult = 6.0;
input showCloud = yes;
input colorBars = yes;

DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
script _avg {
input src = close;
input length = 9;
input mult = 2;

def _atr = ATR(length) * mult;
def up = hl2 + _atr;
def dn = hl2 - _atr;
def upper = if src[1] < upper[1] then Min(up, upper[1]) else up;
def lower = if src[1] > lower[1] then Max(dn, lower[1]) else dn;
def os = if src > upper then 1 else if src < lower then 0 else os[1];
def spt = if os == 1 then lower else upper;
def _max = if src crosses spt then Max(src, _max[1]) else if os == 1 then Max(src, _max[1]) else spt;
def _min = if src crosses spt then Min(src, _min[1]) else if os == 0 then Min(src, _min[1]) else spt;
plot return = (_max + _min) / 2;
}

plot Tenkan = _avg(close, tenkan_period, tenkan_mult);
plot Kijun = _avg(close, kijun_period, kijun_mult);
plot TKCrossUp = Tenkan crosses above Kijun;
plot TKCrossDown = Tenkan crosses below Kijun;

def Direction = if TKCrossUp then 1 else if TKCrossDown then -1 else Direction[1];
def senkouA = (kijun + tenkan) / 2;
def senkouB = _avg(close,spanB_period,spanB_mult);
Tenkan.SetDefaultColor(Color.CYAN);
Tenkan.SetLineWeight(2);
Tenkan.HideBubble();
Tenkan.HideTitle();

Kijun.SetDefaultColor(Color.MAGENTA);
Kijun.SetLineWeight(2);
Kijun.HideBubble();
Kijun.HideTitle();

TKCrossUp.SetDefaultColor(Color.CYAN);
TKCrossUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TKCrossUp.SetLineWeight(3);
TKCrossUp.HideBubble();
TKCrossUp.HideTitle();

TKCrossDown.SetDefaultColor(Color.MAGENTA);
TKCrossDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TKCrossDown.SetLineWeight(3);
TKCrossDown.HideBubble();
TKCrossDown.HideTitle();

AddCloud(if showCloud then senkouA[spanB_period] else Double.NaN, if showCloud then senkouB[spanB_period] else Double.NaN, GlobalColor("Bullish"), GlobalColor("Bearish"));

AssignPriceColor(if !colorBars then Color.CURRENT
else if Direction == 1 then GlobalColor("Bullish")
else if Direction == -1 then GlobalColor("Bearish")
else Color.GRAY);
@Micheal
Awesome indicator but I can't get the scan to work. On the cross scan it says too complex. On the "greater than" or "less than", nothing populates no matter the time frame. On the "is true" or "as value" nothing populates either. Have you gotten it to work?
 
@Micheal
Awesome indicator but I can't get the scan to work. On the cross scan it says too complex. On the "greater than" or "less than", nothing populates no matter the time frame. On the "is true" or "as value" nothing populates either. Have you gotten it to work?
Yes, the script is too complex for the scan hacker.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
531 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