NexusFi: Find Your Edge


Home Menu

 





need help with trend lines indicator.


Discussion in TradeStation

Updated
    1. trending_up 2,177 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40

folks, i'm having trouble with trend lines in easy language and i decided to post in this new thread.


i'm trying to create an indicator that would draw something like a gann fan on the high of the first bar after a % increase ( length 60, pctup .5% ) was observed. i would use the same logic the ts % increase paint bar uses, all the rays in the gann fan should continue extending to the right, and in the first bar that this % increase condition stops being true the gann fan should be stop extending right or be deleted.

 
Code
if RateOfChange( Price, Length ) >= PctUp then
	begin
	PlotPaintBar( High, Low, Open, Close, !( "%Incr" ) ) ;
	Alert ;
	end

i have taken a look at all the sample code for trend lines i have been able to find and the closest thing i could find has been this indicator below. however, i haven't been able to make any progress at all in putting this indicator together, i'm not a programmer and this has been really frustrating. i haven't been able to modify the code below so that it would identify the first bar when a % increase of .5 was observed (and also stored its date, time and price coordinates) and then it drew trend lines (a gann fan of 8x1,4x1,...,1x8 lines) that fanned out from the high of that particular bar.


i understand that creating trend lines from easylanguage requires a start and end point for each, but if i have just the start point and want to extend several lines from that point at different gann angles (¿or angles, or slopes?) i haven't been able to think of any possible methods so that i could get ts to do this. ¿does anyone know how does the code for gann fans drawing objects work or where could i find it?


 
Code
 
using elsystem ; 
using elsystem.drawingobjects ; 
using elsystem.drawing ; 
 
variables: 
	TrendLine MyTL( NULL ), 
	DTPoint StartDT( NULL ), 
	DTPoint EndDT( NULL ), 
	DateTime LastPivotLowBar( NULL ), 
	DateTime LastPivotHighBar( NULL ), 
	double LastPivotHigh( 0 ), 
	double LastPivotLow( 0 ) ; 
	 
method void CreateTL() 
	begin 
	{ create the start and end points for the trendline by bar number using the 
	  DTPoint class } 
	StartDT = DTPoint.Create( LastPivotLowBar, LastPivotLow ) ; 
	EndDT = DTPoint.Create( LastPivotHighBar, LastPivotHigh ) ; 
	 
	{ create the trendline } 
	MyTL = TrendLine.Create( StartDT, EndDT ) ; 
	MyTL.Tag = "Entry" astype string ; { this "Tag" property can be used to identify 
	 the trendline; an example can be found in the "MyTL_Click" event handler  
	 below } 
	MyTL.Click += MyTL_Click ; { event handler triggered when the trendline is  
	 clicked } 
	 
	{ set the trendline to NOT be extended left or right } 
	MyTL.ExtLeft = false ; 
	MyTL.ExtRight = false ; 
	 
	MyTL.Color = Color.Cyan ; { set the color of the trendline } 
	MyTL.Style = StyleType.solid ; { set the style of the trendline } 
	MyTL.Weight = 3 ; 
	 
	{ 
	set the trendline to persist once drawn; if set to false, the behavior is  
	similar to the legacy behavior where the TL is deleted unless created on  
	an bar closing tick 
	} 
	MyTL.Persist = true ; 
	end ;	 
 
method void ShowTL() 
	begin 
	{  
	this is how the trendline is "shown" - the trendline is added to the  
	DrawingObjects collection; if you want to remove the trendline, 
	you can use the Delete method of the DrawingObjects class 
	} 
	DrawingObjects.Add( MyTL ) ; 
	end ; 
 
method void MyTL_Click( Object sender, DrawingObjectEventArgs args ) 
variables: TrendLine TL ; 
	begin 
	{ the sender object identifies which trendline was clicked; to use the 
	  trendline object, the sender object needs to be cast as a trendline } 
	TL = sender astype TrendLine ; 
 
	print( "You clicked on the ", DoubleQuote, TL.Tag.ToString(), DoubleQuote, 
	 " trendline." ) ; 
	end ; 
 
once 
	begin 
	{ these DateTime objects will be used to hold the DateTime of the last Pivot 
	  High and last Pivot Low } 
	LastPivotHighBar = new DateTime ; 
	LastPivotLowBar = new DateTime ; 
	end ; 
					 
once ( LastBarOnChartEx  ) { use LastBarOnChartEx for accuracy to the second } 
	begin 
	CreateTL() ; 
	ShowTL() ; 
	end ; 
 
{ look for pivot high and pivot low; store the DateTime of the most recent pivots } 
if PivotHighVSBar( 1, High, 5, 5, 5 + 1 ) <> -1 then { Pivot High found } 
	begin 
	LastPivotHighBar = BarDateTime[5] ; { store the bar DateTime stamp } 
	LastPivotHigh = High[5] ; { store pivot High price } 
	end ; 
 
if PivotLowVSBar( 1, Low, 5, 5, 5 + 1 ) <> -1 then { Pivot Low found } 
	begin 
	LastPivotLowBar = BarDateTime[5] ; { store the bar DateTime stamp } 
	LastPivotLow = Low[5] ; { store pivot Low price } 
	end ; 
	 
Plot1( Close ) ; { dummy plot to let you know the indicator is applied }

what i have in mind would look like this:

this is the paint bar by itself showing that the % increase is being observed.



and as soon as the condition starts being true, i would want the 9 trend lines to be drawn from the high of that bar and to extend right until the % increase condition stopped being true.




if anyone can help me put this indicator together or has any suggestions i would greatly appreciate it. thanks.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Server CPUs and Multicharts 14 or 15 limits
MultiCharts
DOM in QTrader vs Bookmap
Platforms and Indicators
Has anyone taken The Mentor Program from The Trading Gam …
Trading Reviews and Vendors
Need help updating setting in RSqueeze indicator for Nin …
Platforms and Indicators
NinjaTrader indicator for last bar percentages
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Fighting Addiction and Stops
17 thanks
Big Mike in Ecuador
6 thanks
Just another trading journal: PA, Wyckoff & Trends
6 thanks
Want your NinjaTrader indicator created, free?
4 thanks
Joes Trading Garage
4 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 491
Thanks Received: 1,634

maggtrading,

take a look in the Tradestation forum, there are threads with indicators drawing Gann Fans (use the Advanced Search option as it allows you to search for exact phrases like Gann Fan). This might give you some ideas.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40


good day again to everyone,



i have been putting in more time trying to get easylanguage trend lines to work but i have made practically no progress so far. i have some very concrete questions and if anyone with easylanguage knowledge could chip in with the answers that would be great.



first of all, ¿is there any way to get the ts development environment to comment on any errors that are keeping a particular instrument from verifying? every other coding interface i have come across earlier does give a brief description of what went wrong, where and why but with ts there are no explanations as to why any piece of code won't verify.




now, back to the subject of trend lines, as far as i understand, every trend line needs 4 coordinates: starting date and time, starting price level, ending date and time, and ending price level.


i want my trend line to be drawn at the high of the first bar for which a % increase ( length 60, pctup .2% ) is true. i think something similar to this fragment of code below could identify when this condition ( startingpointfan ) becomes true:

 
Code
 
 
  
if RateOfChange( Price, Length ) >= PctUp then percchange = true; 
 
 
if percchange[0] = true and percchange[1] = false then startingpointfan = true; 
 
else startingpointfan = false;
now the question would be, ¿how could i get easylanguage to obtain and store the date, time and price values for the bar where this event last took place? ¿what if i wanted the ts engine to obtain these same values for the bar when price last crossed over an sma or other similar conditions?


the sample code that ts linked to (i included it in my second post) uses a specialized function PivotHighVSBar that returns the location for an event. i also discovered that a similar function exists for the bars where the highest or lowest values were observed, but if i want to obtain and store the data for other kind of events i have no idea whether ts can accomplish this kind of tasks.



the second question would be, once i have managed to get the set of coordinates for the starting point, ¿how could i extend a trend line from that particular point?


from what i have researched, the ending price level could be determined with the following equation, where y2 is the ending price level, y1 is the starting price level, L could be standardized to 1 and a would be the angle we wanted.

y2 = y1 + (L * sin(a))


it is the ending date and time coordinate i'm having the most trouble with. ¿how could i add get the ts engine to go to the next bar on the chart? keep in mind that this code would require tweaks - adjustments for different kinds of bars (daily, weekly, monthly, versus minute - range - momentum - etc). i'm thinking that x2 could be determined very simply by adding 1 to x1.

x2 = x1 + 1


i have tried this very formulation on my indicator but it won't verify:


 
Code
 
 
	LastPivotHighBar = BarDateTime[5] ; 
 
LastPivotHighBarse = LastPivotHighBar + 1;


very well, if anyone has any suggestions or code samples they will be greatly appreciated. thanks, regards.

Reply With Quote




Last Updated on October 16, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Sitemap - Downloads - Top
no new posts