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  

  • Topics

  • Posts

    • NFLX Netflix stock, watch for a top of range breakout at https://stockconsultant.com/?NFLX
    • SMCI Super Micro Computer stock watch, attempting to move higher off the 34.06 support area at https://stockconsultant.com/?SMCI        
    • UPST Upstart stock watch, pull back to 68.15 gap support area at https://stockconsultant.com/?UPST  
    • Why not to simply connect you account to myfxbook which will collect all this data automatically for you? The process you described looks tedious and a bit obsolete but may work for you though.
    • The big breakthrough with AI right now is “natural language computing.”   Meaning, you can speak in natural language to a computer and it can go through huge data sets, make sense out of them, and speak back to you in natural language.   That alone is a huge breakthrough.   The next leg? AI agents. Where they don’t just speak back to you.   They take action. Here’s the definition I like best: an AI agent is an autonomous system that uses tools, memory, and context to accomplish goals that require multiple steps.   Everything from simple tasks (analyzing web traffic) to more complex goals (building executive briefings or optimizing websites).   They can:   > Reason across multiple steps.   >Use tools like a real assistant (Excel spreadsheets, budgeting apps, search engines, etc.)   > Remember things.   And AI agents are not islands. They talk to other agents.   They can collaborate. Specialized agents that excel at narrow tasks can communicate and amplify one another’s strengths—whether it’s reasoning, data processing, or real-time monitoring.   What it Looks Like You wake up one morning, drink your coffee, and tell your AI agent, “I need to save $500 a month.”   It gets to work.   First, it finds all your recurring subscriptions. Turns out you’re paying $8.99 for a streaming service you forgot you had.   It cancels it. Then it calls your internet provider, negotiates a lower bill, and saves you another $40. Finally, it finds you car insurance that’s $200 cheaper per year.   What used to take you hours—digging through statements, talking to customer service reps on hold for an hour, comparing plans—is done while you’re scrolling Twitter.   Another example: one agent tracks your home maintenance needs and gets information from a local weather-monitoring agent. Result: "Rain forecast next week - should we schedule gutter cleaning now?"   Another: an AI agent will plan your vacations (“Book me a week in Italy for under $2,000”), find the cheapest flights, and sort out hotels with a view.   It’ll remind you to pay bills, schedule doctor’s appointments, and track expenses so you’re not wondering where your paycheck went every month.   The old world gave you tools—Excel spreadsheets, search engines, budgeting apps. The new world gives you agents who do the work for you.   Don’t Get Too Scared (or Excited) Yet William Gibson famously said: "The future is already here – it's just not evenly distributed."   AI agents will distribute it. For decades, the tools that billionaires and corporations used to get ahead—personal assistants, financial advisors, lawyers—were out of reach for regular people.   AI agents could change that.   BUT, remember…   We’re in inning one.   AI agents have a ways to go.   They’re imperfect. They mess up. They need more defenses to get ready for prime time.   To be sure, AI is powerful, but it’s not a miracle worker. It’s great at helping humans solve problems, but it’s not going to replace all jobs overnight.   Instead of fearing AI, think of it as a tool to A.] save you time on boring stuff and B.] amplify what you’re already good at. Right now is the BEST time to start experimenting. It’s also the best time to find investments that will “make AI work for you”. Author: Chris Campbell (AltucherConfidential)   Profits from free accurate cryptos signals: https://www.predictmag.com/     
×
×
  • Create New...

Important Information

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