help with Heikin Ashi code : plot Shadows

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

help with Heikin Ashi code : plot Shadows

Postby nuno-online » 13 Jul 2009

is it possible to plot shadows like candles with shadows ?
i had this code below but i only see bars with open and close

Code: Select all

plotPB(haHigh ,haLow ,"heikin-ashi_HL",Black);
SetPlotWidth(1,1);
SetPlotColor(1,Black);
As you can see in the screenshot, the heikin-ashi doesn't have shadows
here is the original code:

Code: Select all

{ Heikin Ashi PaintBarStudy }

Inputs: UpColor(Green), DnColor(Red );
Vars: haClose(0), haOpen(0), haHigh(0), haLow(0), color(0);

If BarNumber = 1 then
begin
haOpen = open;
haClose = (O+H+L+C)/4;
haHigh = MaxList( high, haOpen, haClose);
haLow = MinList( low, haOpen,haClose);
end;

If BarNumber > 1 then
begin
haClose = (O+H+L+C)/4; //average bar price
haOpen = (haOpen [1] + haClose [1])/2; //avg open/close 1 bar ago
haHigh = MaxList(High, haOpen, haClose); //highest of high,open,close
haLow = MinList(Low, haOpen, haClose); // lowest of low, open, close

If haClose > haOpen then
color = UpColor
else
color = DnColor;

PlotPB(haHigh ,haLow ,"heikin-ashiHL",Black);
SetPlotWidth(1,1);
SetPlotColor(1,Black);

PlotPB(haOpen,haClose,"heikin-ashi",color);
SetPlotWidth(1,2);
SetPlotColor(1,color);
end;
thank you for your help
Nuno
Attachments
picture.png
(94.91 KiB) Downloaded 1117 times
Last edited by nuno-online on 16 Jul 2009, edited 1 time in total.

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Someone have an idea?

Postby nuno-online » 16 Jul 2009

Someone have an idea?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 16 Jul 2009

a mock up would be helpful

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 16 Jul 2009

i updated my first post

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 16 Jul 2009

if heikin-ashi have shadows, then it is not heikin-ashi anymore.

you can Format the symbol style to HLC bars behind the heikin-ashi indicator, that should give you the shadow you want.

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 16 Jul 2009

TJ

that give me shadows but theses shadows aren't High / Low 's heikin-ashi

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 16 Jul 2009

try this:

Code: Select all

{ Heikin Ashi PaintBarStudy }

Inputs: UpColor(Green), DnColor(Red );
Vars: haClose(0), haOpen(0), haHigh(0), haLow(0), color(0);

If BarNumber = 1 then
begin
haOpen = open;
haClose = (O+H+L+C)/4;
haHigh = MaxList( high, haOpen, haClose);
haLow = MinList( low, haOpen,haClose);
end;

If BarNumber > 1 then
begin
haClose = (O+H+L+C)/4; //average bar price
haOpen = (haOpen [1] + haClose [1])/2; //avg open/close 1 bar ago
haHigh = MaxList(High, haOpen, haClose); //highest of high,open,close
haLow = MinList(Low, haOpen, haClose); // lowest of low, open, close

If haClose > haOpen then
color = UpColor
else
color = DnColor;

Plot1(haHigh, "BarHigh", Black);
SetPlotWidth(1,1);
SetPlotColor(1,Black);

Plot2(haLow ,"BarLow", Black);
SetPlotWidth(2,1);
SetPlotColor(2,Black);

Plot3(haOpen, "O-BH", color);
SetPlotWidth(3,2);
SetPlotColor(3,color);

Plot4(haClose, "C-BL",color);
SetPlotWidth(4,2);
SetPlotColor(4,color);

end;

code edited at 11:04am

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 16 Jul 2009

here the screenshot
Attachments
picture1.png
(103.22 KiB) Downloaded 1131 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 16 Jul 2009

set plot1 and plot 3 to Bar High
set plot2 and plot 4 to Bar Low

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 19 Jul 2009

Hi TJ

that's ok
thank you very much for your help

Nuno


Return to “User Contributed Studies and Indicator Library”