Pairs Trading via Lower Heikin Ashi Chart

V

Vision

New member
2019 Donor
I want to play around with pairs trading and using Heikin Ashi on a lower chart with a second symbol. Turns out Heikin Ashi code doesn't seem to work with code not in the upper chart. There seems to be problems with the simple arrays being created. Anybody have some ideas or is this a limitation of thinkscript?
 
D

Drgrcrpilot

New member
VIP
Hi, I understand the need to use heikin ashi candles for the averages and to smooth out the chart. but, is there a way to run normal candlestick bars like a shadow/overlay? I like to watch the exact price point. (Yes I know I can watch the bid/ask, but i like to watch the candle forming). Thanks
 
BenTen

BenTen

Administrative
Staff
VIP
@Drgrcrpilot You can use this code below to display Heikin Ashi as a lower study:

Code:
#TSI_HeikinAshi_Bars
# (c) 2009
#Copyright Authorship: ThinkSwimIndicators.com


#==========================================================================
# >>>                H E I K I N - A S H I   B A R S                  <<< [
#.........................................................................[
#                                                                         [
#                         -----=== O ===-----                             [
#                                                                         [
#****COPYRIGHT NOTICE:  "Heikin-Ashi Bars" is free to use by the general  [
# public. Distribution or modification is prohibited. All content, form,  [
# and style, likewise, is protected by copyright.                         [
#                                                                         [
#                         -----=== x ===-----                             [
#                                                                         [
# ThinkSwimIndicators.com  will  CONTINUE  to release FREE indicators--of [
# the  highest quality and caliber--for the Thinkorswim Trading platform, [
# for use by all.  Many of our free indicators surpass the Quality & Use- [
# fulness of indicators offered for "purchase" by other sites. We suggest [
# that  you  visit the free "Learning Center"  at our website for further [
# information on the use of this indicator. "GO: Master the Markets!" (TM)[
#==========================================================================


declare lower;

def haclose = (open + high + low + close) / 4;
rec haopen = compoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] +
close[1]) / 2);
def diff = haclose - haopen;

plot HA_Down = if  diff > 0 and diff[1] >= 0 then 0 else 1;
plot HA_Up = if diff < 0 and diff[1] <= 0 then 0 else 1;

HA_Up.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
HA_Up.AssignValueColor(color.GREEN);
HA_Up.SetLineWeight(5);

HA_Down.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
HA_Down.AssignValueColor(color.RED);
HA_Down.SetLineWeight(5);
**********************************************************
 
M

Moose

New member
This will show you the exact price point on Heikin Ashi

Code:
# sdi_closeLevel
plot cl = close;
cl.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
#hint: plot the close level as a horizontal line with the color determined by its relationship to the heiken-ashi body.
cl.defineColor("above h-a body", color.GREEN);
cl.defineColor("inside h-a body", color.dark_gray);
# author: allen everhart
# date: 7jun2015
cl.defineColor("below h-a body", color.RED);
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale.
# Help me get the word out about my blog by keeping this header
# in place.
cl.assignValueColor(
    if close>ohlc4 && heikinAshiDiff()>0 then cl.color("above h-a body")
    else if close<ohlc4 && heikinAshiDiff()<0 then cl.color("below h-a body")
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale.
    else if heikinAshiDiff()<0 and close>ohlc4-heikinAshiDiff() then  cl.color("above h-a body")
    else if heikinAshiDiff()>0 and close<ohlc4-heikinAshiDiff() then cl.color("below h-a body")
    else cl.color("inside h-a body"));
 
P

Parker427

New member
Can’t believe no one has done this but can someone create the “heikin ashi” indicator into the candles? I’m trying to see if it does a better job than the TTM trend. Or if theirs a code out their can someone link it?
 
BenTen

BenTen

Administrative
Staff
VIP
What do you mean create the heikin ashi indicator into the candles? Are you trying to display heikin ashi candlesticks on your chart? Or do you want to overlay heikin ashi candles on top of the default candles?
 
P

Parker427

New member
What do you mean create the heikin ashi indicator into the candles? Are you trying to display heikin ashi candlesticks on your chart? Or do you want to overlay heikin ashi candles on top of the default candles?
I’m just looking for the indicator. The coding for it. I’ve looked everywhere. I just want it displayed on my chart, not overlap current candles
 
BenTen

BenTen

Administrative
Staff
VIP
@Parker427 Go to your chart't setting > Appearance > Chart Type > Heikin Ashi
 
P

Pensar

Active member
VIP
@Parker427 Maybe this is what you're looking for? Full credit goes to MTS1 of the TSL.

Code:
# HeikinAshiPaintBars_MTSmod180412
# MTS1 1804 based on JQ shared script TSL
# http://tos.mx/jKArTG##
# Updated formula based on http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:heikin_ashi which seems to match ToS HA Chart

def o = open;
def h = high;
def l = low;
def c = close;
def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (o[1] + c[1]) / 2);
HAhigh = Max(Max(h, haopen), haclose[1]);
HAlow = Min(Min(l, haopen), haclose[1]);
HAclose = (open + high + low + close) / 4;
AssignPricecolor(if haclose > haopen
                 then Color.Green
                 else Color.Red);
and here is a MTF version -

Code:
# HeikinAshiPaintBars_MTSmod180412
# MTS1 1804 based on JQ shared script TSL
# http://tos.mx/jKArTG##
# Updated formula based on http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:heikin_ashi which seems to match ToS HA Chart
# Pensar - added MTF 7/30/2020

input agg = aggregationPeriod.TEN_MIN;

def o = open(period = agg);
def h = high(period = agg);
def l = low(period = agg);
def c = close(period = agg);
def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (o[1] + c[1]) / 2);
HAhigh = Max(Max(h, haopen), haclose[1]);
HAlow = Min(Min(l, haopen), haclose[1]);
HAclose = (o + h + l + c) / 4;
AssignPricecolor(if haclose > haopen
                 then Color.Green
                 else Color.Red);
 

Similar threads

Top