#region - Documentation -
{
---------------------------------------------------------------------------------------------------
IDENTIFICATION
==============
Name: RightTLs
Type: Indicator
TS Version: 9.5 Build 17 or later
---------------------------------------------------------------------------------------------------
DOCUMENTATION
=============
This 9.5 sample indicator draws a trendline to the right of the current bar, extended to the right
and shifts the starting point as new bars are added to the chart. A label is also drawn abvoe the
trendline.
---------------------------------------------------------------------------------------------------
HISTORY
=======
Date By Version Task
--------- ------- -------- -------------------------------------------------------------------
01/22/18 chrisd 01.00.00 * Created
---------------------------------------------------------------------------------------------------
}
#endregion
using elsystem;
using elsystem.collections;
using elsystem.drawing;
using elsystem.drawingobjects;
using tsdata.common;
inputs:
int iBarsToRight(2),
string iColorName("Green"),
double iLabelFontSize(9.5),
Lab1("R2"),
Lab2("R1"),
Lab3("PP"),
Lab4("S1"),
Lab5("S2"),
Lab6("Glo Hi"),
Lab7("Glo Lo"),
Lab8("Y Close"),
Lab9("Today Open"),
Val1 (0),
Val2 (0),
Val3 (0),
Val4 (0),
Val5 (0),
Val6 (0),
Val7 (0),
Val8 (0),
Val9 (0);
variables:
TrendLine TL(null),
TextLabel TX(null),
BNPoint BNP(null);
method TrendLine CreateTL(int startBarNo,
double price,
string tlName,
Color MyColor )
variables: TrendLine TL;
begin
TL = TrendLine.Create( BNPoint.Create(startBarNo + MaxBarsBack - 1, price),
BNPoint.Create(startBarNo + MaxBarsBack - 1 + 1, price));
TL.Lock = true;
TL.Color = MyColor;
TL.Weight = Weight.Weight1;
TL.Persist = true;
TL.ExtRight = true;
TL.Name = tlName;
return TL;
end;
method TextLabel CreateTextLabel(int startBarNo,
double price,
string txName,
string labelText,
Color MyColor)
variables: TextLabel TxtLbl;
begin
TxtLbl = TextLabel.Create(BNPoint.Create(startBarNo + MaxBarsBack - 1, Price), labelText);
TxtLbl.Lock = true;
TxtLbl.Color = MyColor;
TxtLbl.Persist = true;
TxtLbl.VStyle = VerticalStyle.Bottom;
TxtLbl.HStyle = HorizontalStyle.Left;
TxtLbl.Font = Font.Create( "Arial", iLabelFontSize );
TxtLbl.Name = txName;
return TxtLbl;
end;
if LastBarOnchartEx and TL = null then
begin
TL = CreateTL(CurrentBar + iBarsToRight, Val1, Lab1, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val1, Lab1, string.Format("{0} {1}", Lab1, Val1),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val2, Lab2, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val2, Lab2, string.Format("{0} {1}", Lab2, Val2),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val3, Lab3, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val3, Lab3, string.Format("{0} {1}", Lab3, Val3),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val4, Lab4, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val4, Lab4, string.Format("{0} {1}", Lab4, Val4),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val5, Lab5, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val5, Lab5, string.Format("{0} {1}", Lab5, Val5),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val6, Lab6, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val6, Lab6, string.Format("{0} {1}", Lab6, Val6),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val7, Lab7, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val7, Lab7, string.Format("{0} {1}", Lab7, Val7),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val8, Lab8, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val8, Lab8, string.Format("{0} {1}", Lab8, Val8),
Color.White);
DrawingObjects.Add(TX);
TL = CreateTL(CurrentBar + iBarsToRight, Val9, Lab9, Color.FromName(iColorName));
DrawingObjects.Add(TL);
TX = CreateTextLabel(CurrentBar + iBarsToRight, Val9, Lab9, string.Format("{0} {1}", Lab9, Val9),
Color.White);
DrawingObjects.Add(TX);
// Move right
if BarStatus(datanum + 1) = 2 and TL <> null then
begin
BNP = BNPoint.Create(CurrentBar + MaxBarsBack - 1 + iBarsToRight, (TL.StartPoint astype BNPoint).Price);
TL.SetStartPoint(BNP);
TX.SetPointValue(BNP);
BNP = BNPoint.Create(CurrentBar + MaxBarsBack - 1 + iBarsToRight + 1, (TL.StartPoint astype BNPoint).Price);
TL.SetEndPoint(BNP);
end;
end;
|