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: 29th March 2024. GBPUSD Analysis: The Pound Trades Higher But For How Long? The global Stocks Markets are closed due to Easter Friday (Good Friday). The NASDAQ continued to follow the sideways trend while other indices again rose. The SNP500 reaches an all-time high, but the NASDAQ remains under pressure from Tesla, Meta and Apple. The Euro continues to trade lower against all major currencies including the US Dollar, Euro and Japanese Yen. The British Pound is the best performing currency during this morning’s Asian session. However, investors are largely fixing their attention on this afternoon’s Core PCE Price Index. GBPUSD – The Pound Trades Higher but For How Long? The GBPUSD is slightly higher than the day’s open and is primary due to the Pound’s strong performance. At the moment, the British Pound is increasing in value against all major currencies. However, the US Dollar Index is also trading 0.10% higher and for this reason there is a slight conflict here. If investors wish to avoid this conflict, the EURUSD is a better option. This is because, the Euro depreciating against the whole currency market avoiding the “tug-of-war” scenario. The GBPUSD is trading slightly lower than the 2-month’s average price and is trading at 49.10 on the RSI. For this reason, the price of the exchange is at a “neutral” level and is signalling neither a buy nor a sell. The day’s price action and future signals are possibly likely to be triggered by this afternoon’s Core PCE Price Index. Analysts expect the Core PCE Price Index to read 0.3% which is slightly lower than the previous month but will result in the annual figure remaining at 2.85%. The PCE rate is different to the inflation rate and the Fed aims for a rate between 1.5% to 2.00%. Therefore, even if the annual rate remains at 2.85%, as analysts expect, it would be too high for the Fed. If the rate increases, even if only slightly, the US Dollar can again renew bullish momentum and the stock market can come under pressure. This includes the SNP500. Investors are focused on the publication of data on the UK’s gross domestic product (GDP) for the last quarter of 2023: the quarterly figures decreased by 0.3%, and 0.2% over the past 12-months. This confirms the state of a shallow recession and the need for stimulation. The data, combined with a cooling labor market and a steady decline in inflation, increase the likelihood that the Bank of England will soon begin interest rate cuts. In the latest meeting the Bank of England representatives did not see any members vote for a hike. USA500 – The SNP500 Rises to New Highs, But Cannot Hold Onto Gains! The price of the SNP500 rises to an all-time high, before correcting 0.33% and ending the day slightly lower than the open price. Nonetheless, the index performs better than the NASDAQ which came under pressure from Tesla, Meta and Apple which hold a higher weight compared to the SNP500. For the SNP500, these 3 stocks hold a weight of 9.25%, whereas the 3 stocks make up 14.63% of the NASDAQ. The SNP500 is also supported by ExxonMobil’s gains due to higher energy prices. The market will remain closed on Friday due to Easter. However, the market will reopen on Monday for the US and investors can expect high volatility. Investors will also need to take into consideration how the PCE Price Index and the changed value of the US Dollar is likely to affect the stock market next week. 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 on how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Michalis Efthymiou Market Analyst 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.
    • MT4 is good and will be good until their parent company keep updating the software, later mt4 users will have to switch to mt5.
    • $SOUN SoundHound AI stock at 5.91 support area , see https://stockconsultant.com/?SOUN
    • $ELEV Elevation Oncology stock bull flag breakout watch , see https://stockconsultant.com/?ELEV
    • $AVDX AvidXchange stock narrow range breakout watch above 13.32 , see https://stockconsultant.com/?AVDX
×
×
  • Create New...

Important Information

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