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

    • ADMA Adma Biologics stock, watch for a range breakout, target 26 area at https://stockconsultant.com/?ADMA
    • URI United Rentals stock, nice rally off 829 support area, watch for top of range breakout at https://stockconsultant.com/?URI
    • Date: 27th November 2024. S&P500 at its 52nd new peak for 2024; USD Firmer, Kiwi & Yen Up. Asia & European Sessions: Wall Street rallied into the close with the S&P500 and Dow registering more record highs with the S&P500 climbing 0.57% to 6045, its 52nd new peak for 2024. The Dow rose 0.28% to 44,860.3 for its 46th record of the year. The NASDAQ advanced 0.63%. Trump named Jamieson Greer as the US Trade Representative and Kevin Hassett to direct the National Economic Council. Greer was intimately involved in Trump’s first-term trade policy decisions. President Biden announced Israel and Hezbollah have reached a cease fire. Over the next 60 days the Lebanese army and state security will take control of their own territory and Israel will gradually withdraw its forces. FOMC minutes: Minutes from the Fed’s latest policy meeting revealed officials leaning toward a cautious approach to future rate cuts. All agreed to cut the rate by -25 bps and nearly all thought risks between achieving employment and inflation goals were “roughly in balance.” Upside risks to the inflation outlook were little changed, and while inflation had eased, it remained elevated. The implied December rate continues to hover around a 50-50 bet as we await the PCE price data Wednesday and the crucial jobs report on December 6. The January 2025 rate is priced for a total of 20 bps in cuts, with -75 bps by January 2026. RBNZ cut its cash rate by 50 bps, yet the Kiwi gained as traders analyzed the central bank’s rate outlook and the governor’s remarks. Chinese government approved a 500 billion yuan ($69 billion) bond quota, enabling two state-owned asset managers to issue bonds for funding projects aimed at spurring economic growth. Today: US inflation and economic growth may provide clues to the Federal Reserve’s next policy move. Financial Markets Performance: The USDIndex has dropped to currently 106.459. The Yen climbed with USDJPY pulling back to 151.82, while NZDUSD jumped to 0.5900 despite the RBNZ’s 50 bps rate cut. Oil prices stabilized at $68.84, with optimism over delayed OPEC+ output increases balancing the reduced geopolitical risk stemming from the ceasefire. Gold rebounds to 2653.54, with next Resistance at 2660-2664. Always trade with strict risk management. Your capital is the single most important aspect of your trading business. Please note that times displayed based on local time zone and are from time of writing this report. Click HERE to access the full HFM Economic calendar. Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding of how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Andria Pichidi HFMarkets Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • RBLX Roblox stock, pull back to 49.2 gap support area at https://stockconsultant.com/?RBLX
    • UHS Universal Health Services stock, nice rally off the 197 support area, from Stocks to Watch at https://stockconsultant.com/?UHS
×
×
  • Create New...

Important Information

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