Welcome to the Traders Laboratory Forums.
TradeStation Custom Programming Discuss projects, ideas, obstacles in programming with TradeStation.

Like Tree2Likes

Reply
Old 07-05-2011, 01:42 PM   #9

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,477 Times in 912 Posts

Re: Trendline Vs Plots

Quote:
Originally Posted by Tradewinds »
...
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


Code:
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;
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
Tradewinds (07-05-2011)
Old 07-05-2011, 02:05 PM   #10

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Trendline Vs Plots

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.



Code:
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;
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 07-05-2011, 02:16 PM   #11

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Trendline Vs Plots

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.


Code:
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;
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 07-05-2011, 02:58 PM   #12

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Trendline Vs Plots

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.

Code:
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;
Tams likes this.
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 07-09-2011, 12:32 AM   #13

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Trendline Vs Plots

I've posted my completed EasyLanguage Auto Support and Resistance line indicator in the INDICATOR section:

http://www.traderslaboratory.com/for...uto-plots.html
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
The Following User Says Thank You to Tradewinds For This Useful Post:
Tams (07-09-2011)

Reply

Tags
trendline

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Instantaneous TrendLine Tams Trading Indicators 43 09-06-2011 11:21 PM
Hideing Plots from Info Window chrisleonard Coding Forum 9 03-02-2011 06:18 AM
RSI Divergence TrendLine aaa Trading Indicators 11 02-25-2011 02:36 PM
Trendline Indicator andypap Coding Forum 1 01-04-2010 07:27 PM
Chart Style Symbol Type Plots in Showme cjstrader5 The Candlestick Corner 7 11-19-2009 11:33 PM

All times are GMT -4. The time now is 09:59 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.