Thats Perfect, Thank you very much!
One more thing,
Can you also help me with this indicator (Swingcounter)
It is a swingcounter that counts a row of green or red candles. I attached a picture to this document. I want it to be exactly like the picture so the numbers need to appear in the graphic chart and not below the chart as an indicator.
{- Filename: Swingteller Perfect -}
procedure TextAboveBar(Bar:integer; Text: string;
fFontSize:integer; AColor:TColor);
begin
with CreateText(BarPosition[Bar], High[Bar] * 1.003, Text) do
begin
VertPosition := vpTop;
HorzPosition := hpCenter;
Color := AColor;
Font.Size := fFontSize;
end;
end;
//=== Procedure ================================================================
procedure TextBelowBar(Bar: integer; Text: string;
fFontSize:integer; AColor:TColor);
begin
with CreateText(BarPosition[Bar], Low[Bar] * 0.997, Text) do
begin
VertPosition := vpBottom;
HorzPosition := hpCenter;
Color := AColor;
Font.Size := fFontSize;
end;
end;
// === BEGIN ===================================================================
var
i,j,iFirst,Lb,UpCount,DownCount,FtSize : integer;
UpCol,DwCol,BUpCol,BDwCol : TColor;
HideCol,HideCnt : boolean;
r: real;
BEGIN
// --- Indicator eigenschappen -----------------------------------------------
with Indicator do
begin
RequiredBars := 10;
NewBand := false;
HiddenParams := true;
end;
// --- Parameters ------------------------------------------------------------
Lb := CreateParameterInteger('Lookback', 1, 10, 4, true);
HideCnt:= CreateParameterBoolean('Hide Count?',false,true);
UpCol := CreateParameterColor('Count Up', clGreen);
DwCol := CreateParameterColor('Count Down', clRed);
FtSize := CreateParameterInteger('FontSize', 10, 25, 8, false);
HideCol:= CreateParameterBoolean('Hide BarColors?',true,false);
BUpCol := CreateParameterColor('BarColor Up', clGreen);
BDwCol := CreateParameterColor('BarColor Down', clRed);
// --- Indicatorberekening & Weergave ----------------------------------------
iFirst := FirstValidIndex(Close);
i := iFirst+Lb;
while i<BarCount do
begin
if (UpCount > 0) and (Close[i] > Close[i-Lb]) then
begin
if not HideCol then SetParentBarColor(i, BUpCol);
DownCount := 0;
UpCount := UpCount+1;
if (UpCount = 9) or (i=BarCount-1) then
begin
if not HideCnt then
for j:=0 to UpCount-1 do TextAboveBar(i-j, IntToStr(UpCount-j), FtSize, UpCol);
UpCount := 0;
i := i+1;
end;
end else
if (DownCount > 0) and (Close[i] < Close[i-Lb]) then
begin
if not HideCol then SetParentBarColor(i, BDwCol);
UpCount := 0;
DownCount := DownCount+1;
if (DownCount = 9) or (i=BarCount-1) then
begin
if not HideCnt then
for j:=0 to DownCount-1 do TextBelowBar(i-j, IntToStr(DownCount-j), FtSize, DwCol);
DownCount := 0;
i := i+1;
end;
end else
if DownCount = 0 then
begin
r := Min(Min(Close[i-1], Close[i-2]), Close[i-3]);
if Close[i] < r then
begin
DownCount := 1;
UpCount := 0;
// if not HideCnt then TextBelowBar(i, IntToStr(DownCount), FtSize, DwCol);
if not HideCol then SetParentBarColor(i, BDwCol);
end;
end else
if UpCount = 0 then
begin
r := Max(Max(Close[i-1], Close[i-2]), Close[i-3]);
if Close[i] > r then
begin
UpCount := 1;
DownCount := 0;
// if not HideCnt then TextAboveBar(i, IntToStr(UpCount), FtSize, UpCol);
if not HideCol then SetParentBarColor(i, BUpCol);
end;
end;
i := i+1;
end;
//=== END ======================================================================
END.