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

    • Date: 22nd November 2024.   BTC flirts with $100K, Stocks higher, Eurozone PMI signals recession risk.   Asia & European Sessions:   Geopolitical risks are back in the spotlight on fears of escalation in the Ukraine-Russia after Russia reportedly used a new ICBM to retaliate against Ukraine’s use of US and UK made missiles to attack inside Russia. The markets continue to assess the election results as President-elect Trump fills in his cabinet choices, with the key Treasury Secretary spot still open. The Fed’s rate path continues to be debated with a -25 bp December cut seen as 50-50. Earnings season is coming to an end after mixed reports, though AI remains a major driver. Profit taking and rebalancing into year-end are adding to gyrations too. Wall Street rallied, led by the Dow’s 1.06% broadbased pop. The S&P500 advanced 0.53% and the NASDAQ inched up 0.03%. Asian stocks rose after  Nvidia’s rally. Nikkei added 1% to 38,415.32 after the Tokyo inflation data slowed to 2.3% in October from 2.5% in the prior month, reaching its lowest level since January. The rally was also supported by chip-related stocks tracked Nvidia. Overnight-indexed swaps indicate that it’s certain the Reserve Bank of New Zealand will cut its policy rate by 50 basis points on Nov. 27, with a 22% chance of a 75 basis points reduction. European stocks futures climbed even though German Q3 GDP growth revised down to 0.1% q/q from the 0.2% q/q reported initially. Cryptocurrency market has gained approximately $1 trillion since Trump’s victory in the Nov. 5 election. Recent announcement for the SEC boosted cryptos. Chair Gary Gensler will step down on January 20, the day Trump is set to be inaugurated. Gensler has pushed for more protections for crypto investors. MicroStrategy Inc.’s plans to accelerate purchases of the token, and the debut of options on US Bitcoin ETFs also support this rally. Trump’s transition team has begun discussions on the possibility of creating a new White House position focused on digital asset policy.     Financial Markets Performance: The US Dollar recovered overnight and closed at 107.00. Bitcoin currently at 99,300,  flirting with a run toward the 100,000 level. The EURUSD drifts below 1.05, the GBPUSD dips to June’s bottom at 1.2570, while USDJPY rebounded to 154.94. The AUDNZD spiked to 2-year highs amid speculation the RBNZ will cut the official cash rate by more than 50 bps next week. Oil surged 2.12% to $70.46. Gold spiked to 2,697 after escalation alerts between Russia and Ukraine. Heightened geopolitical tensions drove investors toward safe-haven assets. Gold has surged by 30% this year. Haven demand balanced out the pressure from a strong USD following mixed US labor data. Silver rose 0.9% to 31.38, while palladium increased by 0.9% to 1,040.85 per ounce. Platinum remained unchanged. 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.
    • A few trending stocks at support BAM MNKD RBBN at https://stockconsultant.com/?MNKD
    • BMBL Bumble stock watch, pull back to 7.94 support area with high trade quality at https://stockconsultant.com/?BMBL
    • LUMN Lumen Technologies stock watch, pull back to 7.43 support area with bullish indicators at https://stockconsultant.com/?LUMN
×
×
  • Create New...

Important Information

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