Ichomoku Kinko Hyo Chart

Stel hier uw vragen over TA-script, of help anderen met het oplossen van hun probleem
Plaats reactie
Theo316
Berichten: 160
Lid geworden op: di dec 04, 2007 2:39 pm

Re: Ichomoku Kinko Hyo Chart

Bericht door Theo316 »

Hallo Eric
Ik kan het niet in een frame krijgen waarvoor excuus maar zou jij bij onderstaande indicator ook
Het kleuren van de candels kunnen toepassen aub

Code: Selecteer alles

{- Filename: 1A_ Cloud_Tar -}
// gewijzigd 17-10-2011
  // gewijzigd 22-07-2020
 procedure ShowLastSignalInfo;
var
 xCol : TColor;
  i: integer;
  s: string;
begin
  { Parameters }
  xCol  := CreateParameterColor('Kleur', RGB(184,134,011));  // Guldenroede
  i := BarCount-1;
  while i >= 0 do
  begin
    if Signals[i] <> sgNeutral then
    begin

      s := DateTimeToStr(DateTime[i]) + ' ' + FormatFloat('0.00', Close[i]);
      case Signals[i] of
      sgEnterLong: s := '1_Trend_BUY_'+s;
      sgEnterShort:s := '1_Trend_SELL_'+s;
      end;
      with CreateText(0, 0, s) do
      begin
        Color :=   xCol
        X1Pct :=99.75;
        HorzPosition := hpLeft;
        Y1Pct :=0.25;
        VertPosition := vpTop;
      end;
      i := 0;
    end;
    i := i-1;
  end;
end;
function AddWorkDays(Date: TDateTime; WorkDays: integer): TDateTime;
var
  n: integer;
Begin
  n := DayOfWeek(Date)-2;
  WorkDays := WorkDays + n;
  Result := (Date-n) + (WorkDays div 5) * 7 + (WorkDays mod 5);
End;
//
function AddMinutes(DateTime: TDateTime;n:integer): TDateTime;
var
   DayNr,Time: TDateTime;
   j,k: integer;
Begin
  Time := frac(DateTime);
  j := 1;
  k := 0;
  While  j < n + 1 do
  begin
    If Time > Instrument.MarketClose Then
      Begin
        k := k + 1;
        Time := Instrument.MarketOpen;
      End;
    DayNr := AddWorkDays(datetime, k);
    Time := Time + barinterval;
    j := j + 1;
    Result := trunc(DayNr) + Time;
  End;
End;
//
function AddMonths(Date: TDateTime; Months: integer): TDateTime;
var
  YY, MM, DD: integer;
Begin
  DecodeDate(Date, YY, MM, DD);
  DD := 1;
  MM := MM + Months;
  YY := YY + ((MM-1) div 12);
  MM := (MM-1) mod 12 + 1;
  if MM <= 0 then
   Begin
    MM := MM + 12;
    YY := YY -1;
   End;
  Result := EncodeDate(YY, MM, DD);
End;
//
function CalcBarPosition(n: integer; CalendarDays: boolean): TDateTime;
Begin
  if BarCount > 0 Then
    Result := BarPosition[BarCount-1]
  else
    Result := Date;
  if BarInterval = 1 then
    if CalendarDays then
      Result := Result + n
    else
      Result := AddWorkDays(Result, n)
  else
  if BarInterval = 7 then
    Result := AddWorkDays(Result, 5*n)
  else
  if BarInterval = 30 then
    Result := AddMonths(Result, n)
  else
  if BarInterval = 90 then
    Result := AddMonths(Result, 3*n)
  else
  if BarInterval = 365 then
    Result := AddMonths(Result, 12*n)
  else
  if BarInterval < 1 then
    Result := AddMinutes(Result,n);
End;
//
Function KleurSelec(Selec:Integer): TColor;
 Begin
   case Selec of
     1:  Result := RGB(000,255,000); //Lime
     2:  Result := RGB(000,200,100); //Groen
     3:  Result := RGB(	232,232,232); //Grijs91
     4:  Result := RGB(255,110,110); //Rood
   end;
   End;
//
Procedure Teken(serie:TSeries;Naam:String;Kleur:Tcolor;Dik:Integer);
Begin
  With CreateLine(Serie) Do
    Begin
      Name  := Naam;
      Color := Kleur;
      Width := Dik;
    End;
End;
//
Procedure TekenVert(a,b,c,d:TSeries;Kleur:Tcolor;Dik:Integer;Soort:TLineType;Naam:String);
Begin
 With  CreateLineOHLC(a,b,c,d) Do
  Begin
    Color    := Kleur;
    Width    := Dik  ;
    LineType := Soort;
    Name     := Naam ;
  End;
End;
//
Procedure TekenTrLine(Dat1:TdateTime;Y1:Real;Dat2:TDateTime;Y2:Real;Kleur:TColor;Dik:Integer;Soort:TLineType);
   Begin
     With CreateTrendLine(Dat1,Y1,Dat2,Y2) Do
      Begin
        Color := Kleur;
        Width := Dik  ;
        Style := Soort;
      End;
   End;
//
   var
    Period1,Period2,Period3,i,j,PositionBar,nFS                   : integer;
    Tenkan_Sen,Kijun_Sen,Chikou_Span,sDotLine                     : TSeries;
    PrevDate                                                      : real ;
    Senkou_Span_A,Senkou_Span_B,Senkou_Span_A_LB,Senkou_Span_B_LB : TSeries;
    sBottom, sTop, sTAR,Shift_A_LB,Shift_B_LB                     : TSeries;
    AColor,ClrSpanA,ClrSpanB,ClrTenkan,ClrKijun,
    Color, ColorUp, ColorDn,ClrChikou,DwCol,UpCol,DwCol2,UpCol2   : TColor;
    Dots,bUseColor                                                : boolean;
    NewDate                                                       : TDateTime;
    x1, x2: TLineCrossings;
  Begin

        nFS    := CreateParameterSelect('     Fill Style','Solid'#9
                                                    'Solid / Shaded'#9
                                                    'Horizontal'#9
                                                    'Vertical'#9
                                                    'FDiagonal'#9
                                                    'BDiagonal'#9
                                                    'Cross'#9
                                                    'DiagCross',1,false);
   UpCol  := CreateParameterColor('     UpColor 1',RGB(000,090,000));             // Donkergroen
   UpCol2 := CreateParameterColor('     UpColor 2 (shaded)', RGB(000,040,000));   // Donkergroen
   DwCol  := CreateParameterColor('     DownColor 1', RGB(120,000,000));         // Rood4/Donkerrood
   DwCol2 := CreateParameterColor('     DownColor 2 (shaded)',RGB(070,000,000)); // Rood4/Donkerrood
   Period1 := CreateParameterInteger('Period1', 1, 999 , 9, true);
   Period2 := CreateParameterInteger('Period2', 1, 999, 26, true);
   Period3 := CreateParameterInteger('Period3', 1, 999, 52, true);
   bUseColor := CreateParameterBoolean('Bars kleuren',false, false);
    ColorUp := CreateParameterColor('Up color',RGB(000,200,100)); //Groen
    ColorDn := CreateParameterColor('Down color',RGB(255,110,110)); //Rood
    Dots            := CreateParameterBoolean('Dots?', false, false);

 With Indicator do
    Begin
      ShortName            :='Trend';
      RequiredBars         := 5 * Maxint(Maxint(Period1,Period2),Period3);
      Indicator.NewBand    := false;
      Indicator.ScaleRange := srCommon;
        HiddenParams := true;
    End;

  Tenkan_Sen        := DivideSeriesBy(AddSeries(HighSeries(High,Period1),LowSeries(Low,Period1)),2);
  Kijun_Sen         := DivideSeriesBy(AddSeries(HighSeries(High,Period2),LowSeries(Low,Period2)),2);
  Chikou_Span       := ShiftSeries(Close,-Period2 );
  Senkou_Span_A     := ShiftSeries(DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2),Period2);
  Senkou_Span_B     := ShiftSeries(DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2),Period2);
  Senkou_Span_A_LB  := DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2);
  Senkou_Span_B_LB  := DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2);
  Shift_A_LB        := ShiftSeries(DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2),1);
  Shift_B_LB        := ShiftSeries(DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2),1);

  ClrSpanA   := KleurSelec(2);    ClrSpanB   := KleurSelec(4);
  ClrTenkan  := KleurSelec(2);    ClrKijun   := KleurSelec(4);     ClrChikou  := KleurSelec(3);

for i := Firstvalidindex(Senkou_Span_B)+1 to barcount-1 do
 Begin
  PrevDate := CalcBarPosition(0, false);
  If i = barcount - 1 then
   Begin
    For j := 1 to Period2 do
    Begin
    NewDate     := CalcBarPosition(j, false);
    PositionBar := Period2 - j;
    TekenTrLine(PrevDate, Shift_B_LB[i-PositionBar], NewDate, Senkou_Span_B_LB[i-PositionBar],ClrSpanB,2,lsSolid);
    TekenTrLine(PrevDate,Shift_A_LB[i-PositionBar],NewDate,Senkou_Span_A_LB[i-PositionBar],ClrSpanA,2,lsSolid);
    If Isvalid(Senkou_Span_A_LB[i-PositionBar]) and Isvalid(Senkou_Span_B_LB[i-PositionBar]) then
    Begin
    AColor:= KleurSelec(4);
    If (Senkou_Span_A_LB[i-PositionBar])>(Senkou_Span_B_LB[i-PositionBar]) Then AColor := KleurSelec(2);
    End;
    TekenTrLine(NewDate , Senkou_Span_A_LB[i-PositionBar], NewDate, Senkou_Span_B_LB[i-PositionBar],AColor,1,lsSolid);
    PrevDate := NewDate;
    End;
   End;
  If Isvalid(Senkou_Span_A[i]) and Isvalid(Senkou_Span_B[i]) Then
    Begin
      SetBarColor(0,i,KleurSelec(2));
      If (Senkou_Span_A[i])>(Senkou_Span_B[i]) Then SetBarColor(0,i,KleurSelec(2));
    End;
 End;
 
x1 := Crossings(Close, MinSeries(Senkou_Span_A, Senkou_Span_B));
x2 := Crossings(Close, MaxSeries(Senkou_Span_A, Senkou_Span_B));
for i:=0 to BarCount-1 do
begin
  if x2[i] = lc1Over2 then EnterLong(i) else
  if x1[i] = lc2Over1 then EnterShort(i);
end;
      for i:=0 to BarCount-1 do
  begin
    if bUseColor then
    begin
      if Signals[i] = sgEnterLong then Color := ColorUp else
        if Signals[i] = sgEnterShort then Color := ColorDn;
      if Color <> 0 then SetParentBarColor(i, Color);
    end;
  end;
 //**
  case nFS of
    0: FillLinesRegion(0, 1, UpCol, DwCol, bsSolid);
    1: FillLinesRegionShaded(0, 1, UpCol2, UpCol, DwCol2, DwCol);
    2: FillLinesRegion(0, 1, UpCol, DwCol, bsHorizontal);
    3: FillLinesRegion(0, 1, UpCol, DwCol, bsVertical);
    4: FillLinesRegion(0, 1, UpCol, DwCol, bsFDiagonal);
    5: FillLinesRegion(0, 1, UpCol, DwCol, bsBDiagonal);
    6: FillLinesRegion(0, 1, UpCol, DwCol, bsCross);
    7: FillLinesRegion(0, 1, UpCol, DwCol, bsDiagCross);
  end;
  // -------------------------------------------

Teken(Senkou_Span_A,'Senkou_Span_A',ClrSpanA ,2);
Teken(Senkou_Span_B,'Senkou_Span_B',ClrSpanB ,2);
Teken(Tenkan_Sen   ,'Tenkan_Sen'   ,ClrTenkan,2);
Teken(Kijun_sen    ,'Kijun-Sen'    ,ClrKijun ,2);
Teken(Chikou_Span  ,'Chikou_Span'  ,ClrChikou,2);

  sBottom := MinSeries(Senkou_Span_A, Senkou_Span_B);
  sTop := MaxSeries(Senkou_Span_A, Senkou_Span_B);
  sTAR := MultiplySeriesBy(DivideSeries(SubtractSeries(Close, sBottom), SubtractSeries(sTop, sBottom)), 100);
    if Dots then sDotLine := Close else sDotLine := CreateSeries(BarCount);
  //************************************************************;
  with CreateLine(sDotLine) do
  begin
    Name     := 'Dot-color';
    LineType := ltDot;
    Color    := clYellow;
    Width    := 3;
  end;
  with createline(sTAR) do
  begin
    Name := 'TAR';
    Color := clWhite;
    LineContent := lcTAR;
    Visible := false;
  end;
  ShowLastSignalInfo;
  END.
Koers sluit boven Span_A Koop Candels groen
Koers sluit onder Span_A Sluit koop Candels Grijs
Koers sluit onder Span_B Verkoop Candels Rood
Koers sluit boven Span_B sluit verkoop Candels Grijs

Ik weet niet of het zo duidelijk is maar boven de cloud groen
In de cloud grijs en onder de cloud Rood
mvg Theo316

Eric
Berichten: 3282
Lid geworden op: za sep 10, 2005 2:41 am
Locatie: Den Haag

Re: Ichomoku Kinko Hyo Chart

Bericht door Eric »

De signalen moeten dus ook veranderen als ik het goed begrijp - er zaten nog geen exit-signalen in.

Code: Selecteer alles

{- Filename: 1A_ Cloud_Tar -}
// gewijzigd 17-10-2011
  // gewijzigd 22-07-2020
 procedure ShowLastSignalInfo;
var
 xCol : TColor;
  i: integer;
  s: string;
begin
  { Parameters }
  xCol  := CreateParameterColor('Kleur', RGB(184,134,011));  // Guldenroede
  i := BarCount-1;
  while i >= 0 do
  begin
    if Signals[i] <> sgNeutral then
    begin

      s := DateTimeToStr(DateTime[i]) + ' ' + FormatFloat('0.00', Close[i]);
      case Signals[i] of
      sgEnterLong: s := '1_Trend_BUY_'+s;
      sgEnterShort:s := '1_Trend_SELL_'+s;
      end;
      with CreateText(0, 0, s) do
      begin
        Color :=   xCol
        X1Pct :=99.75;
        HorzPosition := hpLeft;
        Y1Pct :=0.25;
        VertPosition := vpTop;
      end;
      i := 0;
    end;
    i := i-1;
  end;
end;
function AddWorkDays(Date: TDateTime; WorkDays: integer): TDateTime;
var
  n: integer;
Begin
  n := DayOfWeek(Date)-2;
  WorkDays := WorkDays + n;
  Result := (Date-n) + (WorkDays div 5) * 7 + (WorkDays mod 5);
End;
//
function AddMinutes(DateTime: TDateTime;n:integer): TDateTime;
var
   DayNr,Time: TDateTime;
   j,k: integer;
Begin
  Time := frac(DateTime);
  j := 1;
  k := 0;
  While  j < n + 1 do
  begin
    If Time > Instrument.MarketClose Then
      Begin
        k := k + 1;
        Time := Instrument.MarketOpen;
      End;
    DayNr := AddWorkDays(datetime, k);
    Time := Time + barinterval;
    j := j + 1;
    Result := trunc(DayNr) + Time;
  End;
End;
//
function AddMonths(Date: TDateTime; Months: integer): TDateTime;
var
  YY, MM, DD: integer;
Begin
  DecodeDate(Date, YY, MM, DD);
  DD := 1;
  MM := MM + Months;
  YY := YY + ((MM-1) div 12);
  MM := (MM-1) mod 12 + 1;
  if MM <= 0 then
   Begin
    MM := MM + 12;
    YY := YY -1;
   End;
  Result := EncodeDate(YY, MM, DD);
End;
//
function CalcBarPosition(n: integer; CalendarDays: boolean): TDateTime;
Begin
  if BarCount > 0 Then
    Result := BarPosition[BarCount-1]
  else
    Result := Date;
  if BarInterval = 1 then
    if CalendarDays then
      Result := Result + n
    else
      Result := AddWorkDays(Result, n)
  else
  if BarInterval = 7 then
    Result := AddWorkDays(Result, 5*n)
  else
  if BarInterval = 30 then
    Result := AddMonths(Result, n)
  else
  if BarInterval = 90 then
    Result := AddMonths(Result, 3*n)
  else
  if BarInterval = 365 then
    Result := AddMonths(Result, 12*n)
  else
  if BarInterval < 1 then
    Result := AddMinutes(Result,n);
End;
//
Function KleurSelec(Selec:Integer): TColor;
 Begin
   case Selec of
     1:  Result := RGB(000,255,000); //Lime
     2:  Result := RGB(000,200,100); //Groen
     3:  Result := RGB(	232,232,232); //Grijs91
     4:  Result := RGB(255,110,110); //Rood
   end;
   End;
//
Procedure Teken(serie:TSeries;Naam:String;Kleur:Tcolor;Dik:Integer);
Begin
  With CreateLine(Serie) Do
    Begin
      Name  := Naam;
      Color := Kleur;
      Width := Dik;
    End;
End;
//
Procedure TekenVert(a,b,c,d:TSeries;Kleur:Tcolor;Dik:Integer;Soort:TLineType;Naam:String);
Begin
 With  CreateLineOHLC(a,b,c,d) Do
  Begin
    Color    := Kleur;
    Width    := Dik  ;
    LineType := Soort;
    Name     := Naam ;
  End;
End;
//
Procedure TekenTrLine(Dat1:TdateTime;Y1:Real;Dat2:TDateTime;Y2:Real;Kleur:TColor;Dik:Integer;Soort:TLineType);
   Begin
     With CreateTrendLine(Dat1,Y1,Dat2,Y2) Do
      Begin
        Color := Kleur;
        Width := Dik  ;
        Style := Soort;
      End;
   End;
//
   var
    Period1,Period2,Period3,i,j,PositionBar,nFS                   : integer;
    Tenkan_Sen,Kijun_Sen,Chikou_Span,sDotLine                     : TSeries;
    PrevDate                                                      : real ;
    Senkou_Span_A,Senkou_Span_B,Senkou_Span_A_LB,Senkou_Span_B_LB : TSeries;
    sBottom, sTop, sTAR,Shift_A_LB,Shift_B_LB                     : TSeries;
    AColor,ClrSpanA,ClrSpanB,ClrTenkan,ClrKijun,
    Color, ColorUp, ColorDn,ClrChikou,DwCol,UpCol,DwCol2,UpCol2   : TColor;
    Dots,bUseColor                                                : boolean;
    NewDate                                                       : TDateTime;
    x1, x2: TLineCrossings;
  Begin

        nFS    := CreateParameterSelect('     Fill Style','Solid'#9
                                                    'Solid / Shaded'#9
                                                    'Horizontal'#9
                                                    'Vertical'#9
                                                    'FDiagonal'#9
                                                    'BDiagonal'#9
                                                    'Cross'#9
                                                    'DiagCross',1,false);
   UpCol  := CreateParameterColor('     UpColor 1',RGB(000,090,000));             // Donkergroen
   UpCol2 := CreateParameterColor('     UpColor 2 (shaded)', RGB(000,040,000));   // Donkergroen
   DwCol  := CreateParameterColor('     DownColor 1', RGB(120,000,000));         // Rood4/Donkerrood
   DwCol2 := CreateParameterColor('     DownColor 2 (shaded)',RGB(070,000,000)); // Rood4/Donkerrood
   Period1 := CreateParameterInteger('Period1', 1, 999 , 9, true);
   Period2 := CreateParameterInteger('Period2', 1, 999, 26, true);
   Period3 := CreateParameterInteger('Period3', 1, 999, 52, true);
   bUseColor := CreateParameterBoolean('Bars kleuren',false, false);
    ColorUp := CreateParameterColor('Up color',RGB(000,200,100)); //Groen
    ColorDn := CreateParameterColor('Down color',RGB(255,110,110)); //Rood
    Dots            := CreateParameterBoolean('Dots?', false, false);

 With Indicator do
    Begin
      ShortName            :='Trend';
      RequiredBars         := 5 * Maxint(Maxint(Period1,Period2),Period3);
      Indicator.NewBand    := false;
      Indicator.ScaleRange := srCommon;
        HiddenParams := true;
    End;

  Tenkan_Sen        := DivideSeriesBy(AddSeries(HighSeries(High,Period1),LowSeries(Low,Period1)),2);
  Kijun_Sen         := DivideSeriesBy(AddSeries(HighSeries(High,Period2),LowSeries(Low,Period2)),2);
  Chikou_Span       := ShiftSeries(Close,-Period2 );
  Senkou_Span_A     := ShiftSeries(DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2),Period2);
  Senkou_Span_B     := ShiftSeries(DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2),Period2);
  Senkou_Span_A_LB  := DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2);
  Senkou_Span_B_LB  := DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2);
  Shift_A_LB        := ShiftSeries(DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2),1);
  Shift_B_LB        := ShiftSeries(DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2),1);

  ClrSpanA   := KleurSelec(2);    ClrSpanB   := KleurSelec(4);
  ClrTenkan  := KleurSelec(2);    ClrKijun   := KleurSelec(4);     ClrChikou  := KleurSelec(3);

for i := Firstvalidindex(Senkou_Span_B)+1 to barcount-1 do
 Begin
  PrevDate := CalcBarPosition(0, false);
  If i = barcount - 1 then
   Begin
    For j := 1 to Period2 do
    Begin
    NewDate     := CalcBarPosition(j, false);
    PositionBar := Period2 - j;
    TekenTrLine(PrevDate, Shift_B_LB[i-PositionBar], NewDate, Senkou_Span_B_LB[i-PositionBar],ClrSpanB,2,lsSolid);
    TekenTrLine(PrevDate,Shift_A_LB[i-PositionBar],NewDate,Senkou_Span_A_LB[i-PositionBar],ClrSpanA,2,lsSolid);
    If Isvalid(Senkou_Span_A_LB[i-PositionBar]) and Isvalid(Senkou_Span_B_LB[i-PositionBar]) then
    Begin
    AColor:= KleurSelec(4);
    If (Senkou_Span_A_LB[i-PositionBar])>(Senkou_Span_B_LB[i-PositionBar]) Then AColor := KleurSelec(2);
    End;
    TekenTrLine(NewDate , Senkou_Span_A_LB[i-PositionBar], NewDate, Senkou_Span_B_LB[i-PositionBar],AColor,1,lsSolid);
    PrevDate := NewDate;
    End;
   End;
  If Isvalid(Senkou_Span_A[i]) and Isvalid(Senkou_Span_B[i]) Then
    Begin
      SetBarColor(0,i,KleurSelec(2));
      If (Senkou_Span_A[i])>(Senkou_Span_B[i]) Then SetBarColor(0,i,KleurSelec(2));
    End;
 End;
 
  x1 := Crossings(Close, MinSeries(Senkou_Span_A, Senkou_Span_B));
  x2 := Crossings(Close, MaxSeries(Senkou_Span_A, Senkou_Span_B));
  for i:=0 to BarCount-1 do
  begin
    if x2[i] = lc1Over2 then
    begin
      EnterLong(i);
      Color := ColorUp;
    end else
    if x2[i] = lc2Over1 then
    begin
      ExitAny(i);
      Color := clSilver;
    end else
    if x1[i] = lc2Over1 then
    begin
      EnterShort(i);
      Color := ColorDn;
    end else
    if x1[i] = lc1Over2 then
    begin
      ExitAny(i);
      Color := clSilver;
    end;
      
    if bUseColor then
    begin
      if Color <> 0 then SetParentBarColor(i, Color);
    end;
  end;
 //**
  case nFS of
    0: FillLinesRegion(0, 1, UpCol, DwCol, bsSolid);
    1: FillLinesRegionShaded(0, 1, UpCol2, UpCol, DwCol2, DwCol);
    2: FillLinesRegion(0, 1, UpCol, DwCol, bsHorizontal);
    3: FillLinesRegion(0, 1, UpCol, DwCol, bsVertical);
    4: FillLinesRegion(0, 1, UpCol, DwCol, bsFDiagonal);
    5: FillLinesRegion(0, 1, UpCol, DwCol, bsBDiagonal);
    6: FillLinesRegion(0, 1, UpCol, DwCol, bsCross);
    7: FillLinesRegion(0, 1, UpCol, DwCol, bsDiagCross);
  end;
  // -------------------------------------------

  Teken(Senkou_Span_A,'Senkou_Span_A',ClrSpanA ,2);
  Teken(Senkou_Span_B,'Senkou_Span_B',ClrSpanB ,2);
  Teken(Tenkan_Sen   ,'Tenkan_Sen'   ,ClrTenkan,2);
  Teken(Kijun_sen    ,'Kijun-Sen'    ,ClrKijun ,2);
  Teken(Chikou_Span  ,'Chikou_Span'  ,ClrChikou,2);

  sBottom := MinSeries(Senkou_Span_A, Senkou_Span_B);
  sTop := MaxSeries(Senkou_Span_A, Senkou_Span_B);
  sTAR := MultiplySeriesBy(DivideSeries(SubtractSeries(Close, sBottom), SubtractSeries(sTop, sBottom)), 100);
  if Dots then sDotLine := Close else sDotLine := CreateSeries(BarCount);
  //************************************************************;

  with CreateLine(sDotLine) do
  begin
    Name     := 'Dot-color';
    LineType := ltDot;
    Color    := clYellow;
    Width    := 3;
  end;
  with createline(sTAR) do
  begin
    Name := 'TAR';
    Color := clWhite;
    LineContent := lcTAR;
    Visible := false;
  end;

  ShowLastSignalInfo;
END.
---
Eric

Theo316
Berichten: 160
Lid geworden op: di dec 04, 2007 2:39 pm

Re: Ichomoku Kinko Hyo Chart

Bericht door Theo316 »

Hallo Eric
Dank je zo ver
Maar inderdaad ik zie geen exit signaal als de candel in de cloud sluit en ik zie ook niet dat de candel
gray kleurt als de candel in de cloud is
Ik zie bij parameters alleen de up color en down color staan
Zou je hier nog even naar willen kijken of zie ik iets over het hoofd ?
bvd Theo316

Eric
Berichten: 3282
Lid geworden op: za sep 10, 2005 2:41 am
Locatie: Den Haag

Re: Ichomoku Kinko Hyo Chart

Bericht door Eric »

Je kunt de neutral kleur nu ook instellen als parameter.

Code: Selecteer alles

{- Filename: 1A_ Cloud_Tar -}
// gewijzigd 17-10-2011
  // gewijzigd 22-07-2020
 procedure ShowLastSignalInfo;
var
 xCol : TColor;
  i: integer;
  s: string;
begin
  { Parameters }
  xCol  := CreateParameterColor('Kleur', RGB(184,134,011));  // Guldenroede
  i := BarCount-1;
  while i >= 0 do
  begin
    if Signals[i] <> sgNeutral then
    begin

      s := DateTimeToStr(DateTime[i]) + ' ' + FormatFloat('0.00', Close[i]);
      case Signals[i] of
      sgEnterLong: s := '1_Trend_BUY_'+s;
      sgEnterShort:s := '1_Trend_SELL_'+s;
      end;
      with CreateText(0, 0, s) do
      begin
        Color :=   xCol
        X1Pct :=99.75;
        HorzPosition := hpLeft;
        Y1Pct :=0.25;
        VertPosition := vpTop;
      end;
      i := 0;
    end;
    i := i-1;
  end;
end;
function AddWorkDays(Date: TDateTime; WorkDays: integer): TDateTime;
var
  n: integer;
Begin
  n := DayOfWeek(Date)-2;
  WorkDays := WorkDays + n;
  Result := (Date-n) + (WorkDays div 5) * 7 + (WorkDays mod 5);
End;
//
function AddMinutes(DateTime: TDateTime;n:integer): TDateTime;
var
   DayNr,Time: TDateTime;
   j,k: integer;
Begin
  Time := frac(DateTime);
  j := 1;
  k := 0;
  While  j < n + 1 do
  begin
    If Time > Instrument.MarketClose Then
      Begin
        k := k + 1;
        Time := Instrument.MarketOpen;
      End;
    DayNr := AddWorkDays(datetime, k);
    Time := Time + barinterval;
    j := j + 1;
    Result := trunc(DayNr) + Time;
  End;
End;
//
function AddMonths(Date: TDateTime; Months: integer): TDateTime;
var
  YY, MM, DD: integer;
Begin
  DecodeDate(Date, YY, MM, DD);
  DD := 1;
  MM := MM + Months;
  YY := YY + ((MM-1) div 12);
  MM := (MM-1) mod 12 + 1;
  if MM <= 0 then
   Begin
    MM := MM + 12;
    YY := YY -1;
   End;
  Result := EncodeDate(YY, MM, DD);
End;
//
function CalcBarPosition(n: integer; CalendarDays: boolean): TDateTime;
Begin
  if BarCount > 0 Then
    Result := BarPosition[BarCount-1]
  else
    Result := Date;
  if BarInterval = 1 then
    if CalendarDays then
      Result := Result + n
    else
      Result := AddWorkDays(Result, n)
  else
  if BarInterval = 7 then
    Result := AddWorkDays(Result, 5*n)
  else
  if BarInterval = 30 then
    Result := AddMonths(Result, n)
  else
  if BarInterval = 90 then
    Result := AddMonths(Result, 3*n)
  else
  if BarInterval = 365 then
    Result := AddMonths(Result, 12*n)
  else
  if BarInterval < 1 then
    Result := AddMinutes(Result,n);
End;
//
Function KleurSelec(Selec:Integer): TColor;
 Begin
   case Selec of
     1:  Result := RGB(000,255,000); //Lime
     2:  Result := RGB(000,200,100); //Groen
     3:  Result := RGB(	232,232,232); //Grijs91
     4:  Result := RGB(255,110,110); //Rood
   end;
   End;
//
Procedure Teken(serie:TSeries;Naam:String;Kleur:Tcolor;Dik:Integer);
Begin
  With CreateLine(Serie) Do
    Begin
      Name  := Naam;
      Color := Kleur;
      Width := Dik;
    End;
End;
//
Procedure TekenVert(a,b,c,d:TSeries;Kleur:Tcolor;Dik:Integer;Soort:TLineType;Naam:String);
Begin
 With  CreateLineOHLC(a,b,c,d) Do
  Begin
    Color    := Kleur;
    Width    := Dik  ;
    LineType := Soort;
    Name     := Naam ;
  End;
End;
//
Procedure TekenTrLine(Dat1:TdateTime;Y1:Real;Dat2:TDateTime;Y2:Real;Kleur:TColor;Dik:Integer;Soort:TLineType);
   Begin
     With CreateTrendLine(Dat1,Y1,Dat2,Y2) Do
      Begin
        Color := Kleur;
        Width := Dik  ;
        Style := Soort;
      End;
   End;
//
   var
    Period1,Period2,Period3,i,j,PositionBar,nFS                   : integer;
    Tenkan_Sen,Kijun_Sen,Chikou_Span,sDotLine                     : TSeries;
    PrevDate                                                      : real ;
    Senkou_Span_A,Senkou_Span_B,Senkou_Span_A_LB,Senkou_Span_B_LB : TSeries;
    sBottom, sTop, sTAR,Shift_A_LB,Shift_B_LB                     : TSeries;
    AColor,ClrSpanA,ClrSpanB,ClrTenkan,ClrKijun,
    Color, ColorUp, ColorDn,ColorNeu,ClrChikou,DwCol,UpCol,DwCol2,UpCol2   : TColor;
    Dots,bUseColor                                                : boolean;
    NewDate                                                       : TDateTime;
    x1, x2: TLineCrossings;
  Begin

        nFS    := CreateParameterSelect('     Fill Style','Solid'#9
                                                    'Solid / Shaded'#9
                                                    'Horizontal'#9
                                                    'Vertical'#9
                                                    'FDiagonal'#9
                                                    'BDiagonal'#9
                                                    'Cross'#9
                                                    'DiagCross',1,false);
   UpCol  := CreateParameterColor('     UpColor 1',RGB(000,090,000));             // Donkergroen
   UpCol2 := CreateParameterColor('     UpColor 2 (shaded)', RGB(000,040,000));   // Donkergroen
   DwCol  := CreateParameterColor('     DownColor 1', RGB(120,000,000));         // Rood4/Donkerrood
   DwCol2 := CreateParameterColor('     DownColor 2 (shaded)',RGB(070,000,000)); // Rood4/Donkerrood
   Period1 := CreateParameterInteger('Period1', 1, 999 , 9, true);
   Period2 := CreateParameterInteger('Period2', 1, 999, 26, true);
   Period3 := CreateParameterInteger('Period3', 1, 999, 52, true);
   bUseColor := CreateParameterBoolean('Bars kleuren',true, false);
    ColorUp := CreateParameterColor('Up color',RGB(000,200,100)); //Groen
    ColorDn := CreateParameterColor('Down color',RGB(255,110,110)); //Rood
    ColorNeu:= CreateParameterColor('Neutral color',clSilver); //Rood
    Dots            := CreateParameterBoolean('Dots?', false, false);

 With Indicator do
    Begin
      ShortName            :='Trend';
      RequiredBars         := 5 * Maxint(Maxint(Period1,Period2),Period3);
      Indicator.NewBand    := false;
      Indicator.ScaleRange := srCommon;
        HiddenParams := true;
    End;

  Tenkan_Sen        := DivideSeriesBy(AddSeries(HighSeries(High,Period1),LowSeries(Low,Period1)),2);
  Kijun_Sen         := DivideSeriesBy(AddSeries(HighSeries(High,Period2),LowSeries(Low,Period2)),2);
  Chikou_Span       := ShiftSeries(Close,-Period2 );
  Senkou_Span_A     := ShiftSeries(DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2),Period2);
  Senkou_Span_B     := ShiftSeries(DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2),Period2);
  Senkou_Span_A_LB  := DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2);
  Senkou_Span_B_LB  := DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2);
  Shift_A_LB        := ShiftSeries(DivideSeriesBy(AddSeries(Tenkan_Sen,Kijun_Sen),2),1);
  Shift_B_LB        := ShiftSeries(DivideSeriesBy(AddSeries(HighSeries(High,Period3),LowSeries(Low,Period3)),2),1);

  ClrSpanA   := KleurSelec(2);    ClrSpanB   := KleurSelec(4);
  ClrTenkan  := KleurSelec(2);    ClrKijun   := KleurSelec(4);     ClrChikou  := KleurSelec(3);

for i := Firstvalidindex(Senkou_Span_B)+1 to barcount-1 do
 Begin
  PrevDate := CalcBarPosition(0, false);
  If i = barcount - 1 then
   Begin
    For j := 1 to Period2 do
    Begin
    NewDate     := CalcBarPosition(j, false);
    PositionBar := Period2 - j;
    TekenTrLine(PrevDate, Shift_B_LB[i-PositionBar], NewDate, Senkou_Span_B_LB[i-PositionBar],ClrSpanB,2,lsSolid);
    TekenTrLine(PrevDate,Shift_A_LB[i-PositionBar],NewDate,Senkou_Span_A_LB[i-PositionBar],ClrSpanA,2,lsSolid);
    If Isvalid(Senkou_Span_A_LB[i-PositionBar]) and Isvalid(Senkou_Span_B_LB[i-PositionBar]) then
    Begin
    AColor:= KleurSelec(4);
    If (Senkou_Span_A_LB[i-PositionBar])>(Senkou_Span_B_LB[i-PositionBar]) Then AColor := KleurSelec(2);
    End;
    TekenTrLine(NewDate , Senkou_Span_A_LB[i-PositionBar], NewDate, Senkou_Span_B_LB[i-PositionBar],AColor,1,lsSolid);
    PrevDate := NewDate;
    End;
   End;
  If Isvalid(Senkou_Span_A[i]) and Isvalid(Senkou_Span_B[i]) Then
    Begin
      SetBarColor(0,i,KleurSelec(2));
      If (Senkou_Span_A[i])>(Senkou_Span_B[i]) Then SetBarColor(0,i,KleurSelec(2));
    End;
 End;
 
  x1 := Crossings(Close, MinSeries(Senkou_Span_A, Senkou_Span_B));
  x2 := Crossings(Close, MaxSeries(Senkou_Span_A, Senkou_Span_B));
  for i:=0 to BarCount-1 do
  begin
    if x2[i] = lc1Over2 then
    begin
      EnterLong(i);
      Color := ColorUp;
    end else
    if x1[i] = lc2Over1 then
    begin
      EnterShort(i);
      Color := ColorDn;
    end else
    if x2[i] = lc2Over1 then
    begin
      ExitAny(i);
      Color := ColorNeu;
    end else
    if x1[i] = lc1Over2 then
    begin
      ExitAny(i);
      Color := ColorNeu;
    end;
      
    if bUseColor then
    begin
      if Color <> 0 then SetParentBarColor(i, Color);
    end;
  end;
 //**
  case nFS of
    0: FillLinesRegion(0, 1, UpCol, DwCol, bsSolid);
    1: FillLinesRegionShaded(0, 1, UpCol2, UpCol, DwCol2, DwCol);
    2: FillLinesRegion(0, 1, UpCol, DwCol, bsHorizontal);
    3: FillLinesRegion(0, 1, UpCol, DwCol, bsVertical);
    4: FillLinesRegion(0, 1, UpCol, DwCol, bsFDiagonal);
    5: FillLinesRegion(0, 1, UpCol, DwCol, bsBDiagonal);
    6: FillLinesRegion(0, 1, UpCol, DwCol, bsCross);
    7: FillLinesRegion(0, 1, UpCol, DwCol, bsDiagCross);
  end;
  // -------------------------------------------

  Teken(Senkou_Span_A,'Senkou_Span_A',ClrSpanA ,2);
  Teken(Senkou_Span_B,'Senkou_Span_B',ClrSpanB ,2);
  Teken(Tenkan_Sen   ,'Tenkan_Sen'   ,ClrTenkan,2);
  Teken(Kijun_sen    ,'Kijun-Sen'    ,ClrKijun ,2);
  Teken(Chikou_Span  ,'Chikou_Span'  ,ClrChikou,2);

  sBottom := MinSeries(Senkou_Span_A, Senkou_Span_B);
  sTop := MaxSeries(Senkou_Span_A, Senkou_Span_B);
  sTAR := MultiplySeriesBy(DivideSeries(SubtractSeries(Close, sBottom), SubtractSeries(sTop, sBottom)), 100);
  if Dots then sDotLine := Close else sDotLine := CreateSeries(BarCount);
  //************************************************************;

  with CreateLine(sDotLine) do
  begin
    Name     := 'Dot-color';
    LineType := ltDot;
    Color    := clYellow;
    Width    := 3;
  end;
  with createline(sTAR) do
  begin
    Name := 'TAR';
    Color := clWhite;
    LineContent := lcTAR;
    Visible := false;
  end;

  ShowLastSignalInfo;
END.
---
Eric
Bijlagen
aex.GIF

Theo316
Berichten: 160
Lid geworden op: di dec 04, 2007 2:39 pm

Re: Ichomoku Kinko Hyo Chart

Bericht door Theo316 »

Dankjewel Eric ga er mee stoeien
Nog 1 vraag
Bij parameters kun je de kleuren veranderen ivm achtergrond
De up en down color veranderd wel neutral niet enig idee wat hier mis gaat

Eric
Berichten: 3282
Lid geworden op: za sep 10, 2005 2:41 am
Locatie: Den Haag

Re: Ichomoku Kinko Hyo Chart

Bericht door Eric »

Klopt, nog een keer de laatste versie installeren lost dit foutje ook op.

---
Eric

Theo316
Berichten: 160
Lid geworden op: di dec 04, 2007 2:39 pm

Re: Ichomoku Kinko Hyo Chart

Bericht door Theo316 »

Bedankt maar weer

Plaats reactie