Extending the Trendlines

dima777

Member
Messages
85
Likes
1
Hi there!
I wonder if it is possible to have the TradeStation extend to the right all automatic trendlines when it plots them. Thanks!I am posting the code for the automatc trendlines below:
Code:
{*******************************************************************
Description	: This Indicator plots TrendLines-Automatic
Provided By	: Omega Research, Inc. (c) Copyright 1999 
********************************************************************}

Inputs: RHStren(4), RLStren(4), History("No"), RHColor("Red"), RLColor("Blue"), AlrtType("IntraBar");;
Variables: RHTLRef(-1), RHTLRef2(-1), RHSet(-1), RHSet2(-1), RHArrayVal(0), RHColorVar(0), RLColorVar(0), BarsPast(0);
Variables: RLTLRef(-1), RLTLRef2(-1), RLSet(-1), RLSet2(-1),RLArrayVal(0), RHTLBrk(False), RLTLBrk(False);
Arrays: RHDate[10](0), RHTime[10](0), RHVal[10](0);
Arrays: RLDate[10](99999), RLTime[10](99999), RLVal[10](99999);

If currentbar=1 Then Begin
	BarsPast = 10;
	RHColorVar = StrColortoNum(RHColor);
	RLColorVar = StrColortoNum(RLColor);
End;

If SwingHighBar(1, High, RHStren, RHStren+1)=RHStren Then Begin
	For Value1 = 9 DownTo 0 Begin
		RHDate[Value1+1] = RHDate[Value1];
		RHTime[Value1+1] = RHTime[Value1];
		RHVal[Value1+1] = RHVal[Value1];
	End;
	RHDate[0] = Date[RHStren];
	RHTime[0] = Time[RHStren];
	RHVal[0] = High[RHStren];

	For Value22 = 1 To 10 Begin
		If RHVal[Value22] > RHVal[0] Then Begin
			RHArrayVal = Value22;
			Value22 = 11;
		End;
	End;

	If Value22 <> 11 Then Begin
		If RHSet >= 0 Then Begin
			If UpperStr(History) = "YES" or UpperStr(History) = "Y" Then Begin
				If RHTLBrk = False Then 
					RHTLRef2 = TL_SetEnd(RHTLRef, Date,Time, TL_GetValue(RHTLRef, Date, Time));
				RHSet2 = TL_SetExtRight(RHTLRef, False);
			End
			Else 
				TL_Delete(RHTLRef);
		End;
		RHTLBrk = False;
		RHTLRef = TL_New(RHDate[RHArrayVal], RHTime[RHArrayVal], RHVal[RHArrayVal], RHDate[0], RHTime[0], RHVal[0]);
		{Error checking To make sure TL was drawn}
		If RHTLRef >= 0 Then Begin
			RHSet = TL_SetExtRight(RHTLRef, True);
			If RHColorVar <> 99 Then 
				Value14 = TL_SetColor(RHTLRef, RHColorVar);
		End;
		If False Then 
			Plot1[RHStren](High[RHStren], "RH ");
	End;
End;

If SwingLowBar(1, Low, RLStren, RLStren+1) = RLStren Then Begin
		For Value1 = 9 DownTo 0 Begin
				RLDate[Value1+1] = RLDate[Value1];
				RLTime[Value1+1] = RLTime[Value1];
				RLVal[Value1+1] = RLVal[Value1];
		End;
		RLDate[0] = Date[RLStren];
		RLTime[0] = Time[RLStren];
		RLVal[0] = Low[RLStren];

		For Value22 = 1 To 10 Begin
			If RLVal[Value22] < RLVal[0] Then Begin
				RLArrayVal = Value22;
				Value22 = 11;
			End;
		End;
		If Value22 <> 11 Then Begin
			If RLSet >= 0 Then Begin
				If (UpperStr(History) = "YES" or UpperStr(History) = "Y")  Then Begin
					If RLTLBrk = False Then 
						RLTLRef2 = TL_SetEnd(RLTLRef, Date, Time, TL_GetValue(RLTLRef, Date, Time));
					RLSet2 = TL_SetExtRight(RLTLRef, False);
				End
				Else 
					TL_Delete(RLTLRef);
			End;
			RLTLBrk = False;
			RLTLRef = TL_New(RLDate[RLArrayVal], RLTime[RLArrayVal], RLVal[RLArrayVal], RLDate[0], RLTime[0], RLVal[0]);
			{Error checking To make sure TL was drawn}
			If RLTLRef >= 0 Then Begin
				RLSet = TL_SetExtRight(RLTLRef, True);
				If RLColorVar <> 99 Then 
					Value14 = TL_SetColor(RLTLRef, RLColorVar);
			End;
			If False Then 
				Plot2[RLStren](Low[RLStren],"RL ");
		End;
End;

If RHSet[BarsPast] >= 0 AND Close[BarsPast] Crosses Over TL_GetValue(RHTLRef, Date[BarsPast], Time[BarsPast]) Then Begin
	RHTLRef2 = TL_SetEnd(RHTLRef, Date, Time, TL_GetValue(RHTLRef, Date, Time));
	RHTLBrk = True;
End;

If RLSet[BarsPast] >= 0 AND Close[BarsPast] Crosses Below TL_GetValue(RLTLRef, Date[BarsPast], Time[BarsPast]) Then Begin
	RLTLRef2 = TL_SetEnd(RLTLRef, Date, Time, TL_GetValue(RLTLRef, Date, Time));
	RLTLBrk = True;
End;

If CheckAlert Then Begin
	If RHSet >= 0 AND UpperStr(AlrtType) = "ONCLOSE" Then 
		TL_SetAlert(RHTLRef, 2)
	Else
		If RHSet >= 0 AND  UpperStr(AlrtType) = "INTRABAR" Then 
			TL_SetAlert(RHTLRef, 1)
		Else
			If RHSet >= 0 Then 
				TL_SetAlert(RHTLRef, 0);

	If RLSet >= 0 AND UpperStr(AlrtType) = "ONCLOSE" Then 
		TL_SetAlert(RLTLRef, 2)
	Else
		If RLSet >= 0 AND  UpperStr(AlrtType) = "INTRABAR" Then 
			TL_SetAlert(RLTLRef, 1)
		Else
			If RLSet >= 0 Then 
				TL_SetAlert(RLTLRef, 0);
End;

Thanks a lot!
Dima
 
i found the solution - just replace flase with true in the couple TL_SetExtRight functions!
 
Hi dima777, i tried this indicator out on Tradestation but all of the lines are black in colour. Is there any way to change this to blue for up lines and red for down lines. Thanks
 
Top