Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

Sign in to follow this  
Tradewinds

Trendline Vs Plots

Recommended Posts

I've read that Plots can be converted to Trendlines in EasyLanguage. What is the difference between a Plot and a Trendline? How is the code different? I'd like to see an example of each. A Plot has the syntax of:

 

PlotN(Expression[,"<PlotName>"[,ForeColor[,Default[,Width]]]]);

 

Expression is the price value to be plotted, PlotName and ForeColor are self explanatory. Width is how thick you want the plot to be.

 

Text and Trend Lines are created using the Text_XXXXX and TL_XXXXX Reserved Words. The "TL_New" reserved word adds a trendline.

 

TL_New (Reserved Word)

 

This reserved word adds a trendline with the specified starting and ending points to a price chart. It returns a numeric expression corresponding to the ID number of the trendline added to the chart.

 

I want to start a trendline, and have it continue until the next signal.

Share this post


Link to post
Share on other sites

There is the:

 

TL_SetEnd (Reserved Word)

 

This sets the end of the trendline.

 

 

This reserved word changes the end point of the specified trendline; the end point has a later date and time.

 

The trendlines seem like a lot more work, and more difficult to program. I'm also curious as to whether they take more computing power.

 

I'm trying to avoid having connecting lines between trend lines that are at different price levels.

Share this post


Link to post
Share on other sites
I've read that Plots can be converted to Trendlines in EasyLanguage. What is the difference between a Plot and a Trendline? How is the code different? I'd like to see an example of each. A Plot has the syntax of:

 

PlotN(Expression[,"<PlotName>"[,ForeColor[,Default[,Width]]]]);

 

Expression is the price value to be plotted, PlotName and ForeColor are self explanatory. Width is how thick you want the plot to be.

 

Text and Trend Lines are created using the Text_XXXXX and TL_XXXXX Reserved Words. The "TL_New" reserved word adds a trendline.

 

TL_New (Reserved Word)

 

This reserved word adds a trendline with the specified starting and ending points to a price chart. It returns a numeric expression corresponding to the ID number of the trendline added to the chart.

 

I want to start a trendline, and have it continue until the next signal.

 

PLOT is used to paint a price bar, a dot, a dash, a cross, or a line on a chart.

you plot one bar at a time...

when plotting a line, as in a moving average, you get a continuous curving line.

when plotting a line based on a pivot value... you get a straight line.

 

 

Trendline (TL_NEW) is a drawing object.

you define the coordinates -- the starting point and the ending point, in terms of date, time and price, and you get a trendline.

 

a trendline is always straight; it can be a vertical line, horizontal line, or a line that spans diagonally across the chart.

 

a trendline can be made to extend beyond the starting and/or ending point.

 

a trendline can be moved, deleted, attributes modified...

 

well... trendlines can be fun, or headache... depends on which side of the fence you are on.

 

 

more discussions here:

http://www.traderslaboratory.com/forums/coding-forum/5840-trendline-easylanguage.html

 

59.45

Share this post


Link to post
Share on other sites
A trendline can be made to extend beyond the starting and/or ending point.

 

I want a straight line for price level to keep going until the next price level signal fires. I looked at your code in the other thread, and here is what I have so far:

 

var: Peak(False),NoPriorPk(False);
var: ClsDwn(False),ClsUp(False);
var: ht(H);

ClsDwn=c<o;
ClsUp=c>o;

Peak=ClsUp[1] and ClsDwn;
NoPriorPk=Peak[1] = false;

if Peak and NoPriorPk then ht= H[1];


{-- restarts the trendline if a new peak signal fired ---}
var: HiTrget(-1);
if Peak then 
Begin
	HiTrget = tl_new(d, t, H, d, t, H);
end;

{--- extends the trendline from PEAK to current bar ---}
tl_setend(HiTrget, d, t, h);

// To test for a PEAK signal.  Set format to POINTS.
{If Peak and NoPriorPk then 
plot30(l,"Test",Black,5) 
else NoPlot(30);}

 

This won't plot anything. I've tried everything I can think of, and I can not get a trendline to do anything right. I've tried hard coding the dates, times and price levels. I've tried the simplest example I can think of, and I can't get anything to work for a trendline. If anyone can tell me how to make this work, I'd appreciate it.

Share this post


Link to post
Share on other sites
I want a straight line for price level to keep going until the next price level signal fires. I looked at your code in the other thread, and here is what I have so far:

 

var: Peak(False),NoPriorPk(False);
var: ClsDwn(False),ClsUp(False);
var: ht(H);

ClsDwn=c<o;
ClsUp=c>o;

Peak=ClsUp[1] and ClsDwn;
NoPriorPk=Peak[1] = false;

if Peak and NoPriorPk then ht= H[1];


{-- restarts the trendline if a new peak signal fired ---}
var: HiTrget(-1);
if Peak then 
Begin
	HiTrget = tl_new(d, t, H, d, t, H);
end;

{--- extends the trendline from PEAK to current bar ---}
tl_setend(HiTrget, d, t, h);

// To test for a PEAK signal.  Set format to POINTS.
{If Peak and NoPriorPk then 
plot30(l,"Test",Black,5) 
else NoPlot(30);}

 

This won't plot anything. I've tried everything I can think of, and I can not get a trendline to do anything right. I've tried hard coding the dates, times and price levels. I've tried the simplest example I can think of, and I can't get anything to work for a trendline. If anyone can tell me how to make this work, I'd appreciate it.

 

What is your chart resolution?

 

With Tradestation, you can only use minute chart or higher resolutions.

ie no tick chart or any non-time based charts.

 

With MultiCharts, you can draw on any chart format.

Share this post


Link to post
Share on other sites

note correction on Ht

 

var: Peak(False),NoPriorPk(False);
var: ClsDwn(False),ClsUp(False);
var: ht(H);

ClsDwn=c<o;
ClsUp=c>o;

Peak=ClsUp[1] and ClsDwn;
NoPriorPk=Peak[1] = false;

if Peak and NoPriorPk then ht= H[1];


{-- restarts the trendline if a new peak signal fired ---}
var: HiTrget(-1);
if Peak then 
Begin
	HiTrget = tl_new(d, t, Ht, d, t, Ht); // <--- note correction on Ht
end;

{--- extends the trendline from PEAK to current bar ---}
tl_setend(HiTrget, d, t, ht);  // <--- note correction on Ht

// To test for a PEAK signal.  Set format to POINTS.
{If Peak and NoPriorPk then 
plot30(l,"Test",Black,5) 
else NoPlot(30);}

 

chart from above code:

 

attachment.php?attachmentid=25123&stc=1&d=1309835106

5aa7108796dfa_hsitl.png.f57e6d94b18b7ce72e30113ef2ff2f34.png

Share this post


Link to post
Share on other sites

I'm using a 1 minute chart of the @ESU11. I used that code with the change you made, and it still would not plot. I'm wondering if the issue is at least partly related to something other than the indicator. I'm constantly getting a msg that the Axis Scaling is being reset to "No Axis" when I add an indicator to the chart. Attached is a screen shot of the msg. I can get a POINT to plot from my signals, I can get regular plot lines to work, but when I try using a trendline, then it just doesn't work. I may need to post something on the TradeStation support forum.

5aa710879d89e_AxisScaling.thumb.JPG.c92bcd6ab40460dd39b37a43553ced3b.JPG

ES_Chart.thumb.JPG.257f36faef62c1bdbcff408aa118990a.JPG

Share this post


Link to post
Share on other sites

This code does part of what I want. It starts a trendline at one of my PEAK signals.

 

Variable: ID(-1);

If C[1]>O[1] AND Close<O Then Begin
 ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);
 Value1 = TL_SetExtRight(ID, True);
End; 

 

I want the LAST high to be the price level of the trend line if my peak signal fires. So I used "H[1]" for the start price. For the end price, I want the line to be perfectly level and horizontal, so the end price must be the same as the start price. So I used the last high for the end price also.

 

ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);

 

So this is a beginning. Now I need to be able to stop one trend line when the next one starts.

 

This code uses the same logic, but just adds a little bit of detail:

 

var: Peak1(False);

Peak1 = C[1]>O[1] AND Close<O;

Variable: ID(-1);

If Peak1 Then Begin
 ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);
 Value1 = TL_SetExtRight(ID, True);
End; 

Share this post


Link to post
Share on other sites
...

So this is a beginning. Now I need to be able to stop one trend line when the next one starts.

 

...

 

 

note: // <-- add this line

 

 

var: Peak1(False);

Peak1 = C[1]>O[1] AND Close<O;

Variable: ID(-1);

If Peak1 Then 
Begin

   TL_SetExtRight( ID[1] , FALSE);  // <-- add this line

   ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);
   Value1 = TL_SetExtRight(ID, True);
End;

Share this post


Link to post
Share on other sites

This code will delete all the old trend lines. So there is only one trend line at a time. As soon as the new trend line is created, the old trend line is deleted. Note the addition of "OldKeyID"

 

Variable: OldKeyID(-1), ID(-1);

 

So the OldKeyID AND the ID are both being initialized at a value of -1. I'm guessing what happens, is that each new trend line is assigned a successive number. This still doesn't do what I want, I want all the old trend lines to remain on the chart. Maybe I can use the OldKeyID to end the last line instead of delete it.

 

 

 

var: Peak1(False);

Peak1 = C[1]>O[1] AND Close<O;

Variable: OldKeyID(-1), ID(-1);

If Peak1 Then Begin
 OldKeyID = ID;
 ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);
 Value1 = TL_SetExtRight(ID, True);

 If OldKeyID <> -1 Then
 Value1 = TL_Delete(OldKeyID);
End;

Share this post


Link to post
Share on other sites

I made a change, and it didn't give me what I want, but it does give me some more information. Instead of deleting the OldKeyID trend line, I set the Right Extension to "False". What that did, is it left the old trend line in place, but the old trend line is now only 1 bar in length. So the old trend line is still there, but it's not extended to the start of the new trend line. So it looks like I may need to use the "OldKeyID", but instead of deleting it or setting the right extension to False, I need to somehow define where the new end is going to be.

 

 

var: Peak1(False);
Variable: OldKeyID(-1), ID(-1);

Peak1 = C[1]>O[1] AND Close<O;

If Peak1 Then Begin
 OldKeyID = ID;
 ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);
 Value1 = TL_SetExtRight(ID, True);

 If OldKeyID <> -1 Then
 Value1 = TL_SetExtRight(OldKeyID, False);
End;

Share this post


Link to post
Share on other sites

Aah Hah, Hah, Hah Haaaaah!

I think I've done it!!!

I will now take over the world !!!

 

 

The code retrieves the new Start Time from the new trendline, and uses that as the End time for the old trend line. Then the code retrieves the Begin Value from the Old trend line and uses it as the end value for the old trend line. So the old trendline begins and ends at the same price - Horizontal line. But before the End is set for the old trendline, the extension to the right is shut down for the old trend line, but ONLY the Old trend line. So only the current trend line is being extended to the right. This causes the current trend line to be extended in "real time" as the chart is updating. As soon as a new Peak signal fires, the Extension to the Right shuts down and the ending point is defined for the last trendline.

 

var: Peak1(False);
Variable: OldKeyID(-1), ID(-1);
var: NewStartTime(t),OldStartPrice(h);

Peak1 = C[1]>O[1] AND Close<O;

If Peak1 Then Begin
 OldKeyID = ID;
 ID = TL_New(Date[1], Time[1], H[1], Date, Time, H[1]);
 Value1 = TL_SetExtRight(ID, True);

 If OldKeyID <> -1 Then
 Begin
   NewStartTime = TL_GetBeginTime(ID);
   OldStartPrice = TL_GetBeginVal(OldKeyID);
   Value1 = TL_SetExtRight(OldKeyID, False);
   Value2 = TL_SetEnd(OldKeyID, Date, NewStartTime, OldStartPrice);
 End;
End;

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.