Histogram Bars style

How to create strategies and indicators
Message
Author
___________
Posts: 10
Joined: Fri Jan 11, 2008 10:59 am

Histogram Bars style

#1 Postby ___________ » Fri Jan 11, 2008 11:02 am

Hi, i want to use an indicator i made for mt4 in fxt based on the impulse system from alexander elder, i need to read the value from macd histogram, and make something like
If (histcurrentvalue>histpreviousvalue) Then
begin
paint histogram bar green
end
else If (histcurrentvalue<histpreviousvalue) Then
begin
paint histogram bar red
end

i tried something like

If (Diff[index]<Diff[index+1]) Then
begin
SetIndexStyle(2, ds_Fill, psSolid, 1, clRed);
end;
If (Diff[index]>Diff[index+1]) Then
begin
SetIndexStyle(1, ds_Fill, psSolid, 1, clGreen);
end;

But that paint all the below 0 and below 0, and using ds_HistogramFill show no histogram bars, is there a way to achieve this?

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

Re: Histogram Bars style

#2 Postby Terranin » Fri Jan 11, 2008 12:58 pm

___________ wrote:Hi, i want to use an indicator i made for mt4 in fxt based on the impulse system from alexander elder, i need to read the value from macd histogram, and make something like
If (histcurrentvalue>histpreviousvalue) Then
begin
paint histogram bar green
end
else If (histcurrentvalue<histpreviousvalue) Then
begin
paint histogram bar red
end

i tried something like

If (Diff[index]<Diff[index+1]) Then
begin
SetIndexStyle(2, ds_Fill, psSolid, 1, clRed);
end;
If (Diff[index]>Diff[index+1]) Then
begin
SetIndexStyle(1, ds_Fill, psSolid, 1, clGreen);
end;

But that paint all the below 0 and below 0, and using ds_HistogramFill show no histogram bars, is there a way to achieve this?


SetIndexStyle changes style for all buffer.
You need to use 2 visible buffers - one all red, second all green. If you need red bar - then put value in red buffer, if you need green - put value in green buffer. Other values in buffer should be 0 and will not be painted.
And possible one invisible buffer where you store all values.

Code: Select all


// initialization
Diff := CreateIndexBuffer;
buff1 := CreateIndexBuffer;
buff2 := CreateIndexBuffer;

IndicatorBuffers(2); // 2 visible buffers
SetIndexBuffer(0, buff1);
SetIndexStyle(0, ds_Histogram, psSolid, 1, clRed);
SetIndexBuffer(1, buff2);
SetIndexStyle(1, ds_Histogram, psSolid, 1, clGreen);


// calculating
If (Diff[index]<Diff[index+1]) Then
  buff1[index] := Diff[index]
else
  buff1[index] := 0;
 
if (Diff[index]>Diff[index+1]) Then
  buff2[index] := Diff[index]
else
  buff2[index] := 0;
Hasta la vista
Mike

___________
Posts: 10
Joined: Fri Jan 11, 2008 10:59 am

#3 Postby ___________ » Fri Jan 11, 2008 7:56 pm

great, im using the same method for mt4 dunno why i didnt got that in mind lol... ok i will continue the code, thanks


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 23 guests