Problem with Zigzag that prints highs/lows and swing distance - EasyLanguage Programming | futures io social day trading
futures io futures trading


Problem with Zigzag that prints highs/lows and swing distance
Updated: Views / Replies:2,451 / 10
Created: by treydog999 Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

Problem with Zigzag that prints highs/lows and swing distance

  #1 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received

Problem with Zigzag that prints highs/lows and swing distance

90% of the time this thing plots the highs and lows and swing distance correctly but sometimes it doesn't I have played with all the variables but cant figure out what's up. Anyone more experienced can help?

 
Code
// ZigZag Pnts - Text Plots
//Treydog999

inputs: 
	HighLow( True ), 
	RetracePnts( .0005 ), 
	LineColor( Yellow ), 
	LineWidth( 1 ),
	LineStyle ( 1 ) ,
	PlotLines(false),
	PriceOrSwing("Swing"),
	DecimalPlaces(4),
	Color(yellow),
	TextSize(8);
	
variables: 
	SwingMult(0),
	Price(close),
	Price1(close),
	Price2(close),
	var0( 0 ), 
	var1( Price ),                                         
	var2( Date ),                                         
	var3( Time ),                                         
	var4( 0 ),                                                         
	var5( false ), 
	var6( false ), 
	var7( false ), 
	var8( 0 ),
	SwingDistance( 0 ) ;
//Set Swing Mult
SwingMult = MinMove*PriceScale;
//High Low switch
if HighLow = true then begin
	price1 = high;
	price2 = low;
	end;

if highlow = false then begin
	price1 = close;
	price2 = close;
	end;
	                                                          
// Zigzag calcs
var0 = SwingHigh( 1, Price1, 1, 2 ) ;
if var0  <> -1 then 
	begin
		condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
		if condition1 then 			                            
			begin
				var5 = true ;
				var6 = true ;
				var4 = 1 ;
			end 
		else 
		begin 
			condition1 = var4 = 1 and var0 >= var1 ;
			if condition1 then 			                                
			begin
				var5 = true ;
				var7 = true ;
			end;
		end ;
	end 
else 
	begin
	var0 = SwingLow( 1, price2, 1, 2 ) ;
	if var0 <> -1 then 
		begin
			condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
			if condition1 then 				                            
			begin
				var5 = true ;
				var6 = true ;
				var4 = -1 ;
			end 
			else 
			begin 
				condition1 = var4 = -1 and var0 <= var1 ;
				if condition1 then 					                                
				begin
					var5 = true;
					var7 = true ;
				end ;
			end;
		end ;
	end ;

if var5 then 
	                                      
	begin
	var1 = var0 ;
	var2 = Date[1] ;
	var3 = Time[1] ;
	var5 = false ;
	end ;

if var6 and PlotLines = True then 
	                              
	begin
	var8 = TL_New( var2, var3, var1, var2[1], var3[1], 
	 var1[1] ) ;
	TL_SetExtLeft( var8, false ) ;
	TL_SetExtRight( var8, false ) ;
	TL_SetSize( var8, LineWidth ) ;
	TL_SetColor( var8, LineColor ) ;
	tl_setstyle(var8,LineStyle);
	var6 = false ;
	end 
else if var7 and PlotLines = True then 
	                                     
	begin
	TL_SetEnd( var8, var2, var3, var1 ) ;
	var7 = false ;
	end ;

//Text Prints
SwingDistance = absvalue(var1 - var1[1])*SwingMult;

if var4 <> var4[1] and PriceOrSwing = "Price" then
value1 = text_new(var2, var3, var1, numtostr(var1,DecimalPlaces));

if var4 <> var4[1] and PriceOrSwing = "Swing" then
value1 = text_new(var2, var3, var1, numtostr(swingdistance,0));

if var4 <> var4[1] and PriceOrSwing = "Both" then begin
if DecimalPlaces = 4 then
value1 = text_new(var2, var3, var1, numtostr(var1,DecimalPlaces)+ NewLine + "    " + numtostr(swingdistance,0) );
if DecimalPlaces = 2 then
value1 = text_new(var2, var3, var1, numtostr(var1,DecimalPlaces)+ NewLine + "  " + numtostr(swingdistance,0) );
end;

if var4 = -1 then 
	text_setlocation(value1,var2,var3,var1 - truerange*.25);

if var4 = 1 then
	text_setlocation(value1,var2,var3,var1 + truerange*.25);
	
if value1 > 0 then begin
	text_setcolor(value1,color);
	text_setstyle(value1,2,2);
	text_setsize(value1,textsize);

end;	


//debug
//value2 = text_new(var2, var3, var1 + .25*averagetruerange(10) , numtostr(var1,4));
//print(var0:0:4," ", var1:0:4, " ", var2, " ", var3, " ", var4, " ", var5, " ", var6, " ", var7, " ", var8);

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Banned: trolling
NYC + NY / USA
 
Futures Experience: Advanced
Platform: "I trade, therefore, I AM!"; Theme Song: "Atomic Dog!"
Favorite Futures: EMD, 6J, ZB
 
kronie's Avatar
 
Posts: 798 since Oct 2009
Thanks: 216 given, 498 received


I also noticed the inability to push the fibs over, say, using the displacement or +- offset, in this manner the lines and percentages can be located in the clear margin, especially if you set a high number for the margin property

is there anyway to displace right these fibs?

Reply With Quote
 
  #4 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received


kronie View Post
I also noticed the inability to push the fibs over, say, using the displacement or +- offset, in this manner the lines and percentages can be located in the clear margin, especially if you set a high number for the margin property

is there anyway to displace right these fibs?

No you can not displace right or left.

Reply With Quote
 
  #5 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received

Here is an example. all of the plots on this chart except this one is correct. no idea how it does it. the zigzag plot is correct but the exit value which uses the same variable var1 is now the wrong when its set to string. If its not clear i am refering to the 1.3265 13 plot the 2nd 1.3265 is in fact correct.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
 
  #6 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received

any easy language guru's out there lend a helping hand?

Reply With Quote
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

When a current swing high updates by making a higher high (vice versa for the low) you correctly update the trendline end point and text location, but the code is missing the update for the text string. Add this and it should work fine.

Regards,
ABCTG

Reply With Quote
 
  #8 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received


ABCTG View Post
When a current swing high updates by making a higher high (vice versa for the low) you correctly update the trendline end point and text location, but the code is missing the update for the text string. Add this and it should work fine.

Regards,
ABCTG

Yes, I have tried that and also cleaned up the variables. multicharts is stupid as they dont name anything. anyway what happens now is the swing distance when updated does not calculate correctly if there is an update. I have tried several iterations, using TL_GetBeginVal works great but if I choose the option not to plot the lines then i cant grab the value. so i added swingstart variable to extract that but now i on updates i get the distance between the update and the previous end swing so the value can be like 1 tick or something instead of from the start of the move.

 
Code
// ZigZag Pnts - Text Plots
//Treydog999

inputs: 
	HighLow( True ), 
	RetracePnts( .0005 ), 
	LineColor( Yellow ), 
	LineWidth( 1 ),
	LineStyle ( 1 ) ,
	PlotLines(false),
	PriceOrSwing("Both"),
	DecimalPlaces(4),
	Color(yellow),
	TextSize(8);
	
variables: 
	SwingMult(0),
	Price(close),
	Price1(close),
	Price2(close),
	SwingPrice( 0 ), 
	SwingPrice1( Price ),                                         
	SwingDate( Date ),                                         
	SwingTime( Time ),                                         
	TLDir( 0 ),                                                         
	SaveSwing( false ), 
	AddTL( false ), 
	UpdateTL( false ), 
	var8( 0 ),
	SwingDistance( 0 ),
	SwingStart(0) ;
//Set Swing Mult
SwingMult = MinMove*PriceScale;
//High Low switch
if HighLow = true then begin
	price1 = high;
	price2 = low;
	end;

if highlow = false then begin
	price1 = close;
	price2 = close;
	end;
	                                                          
// Zigzag calcs
SwingPrice = SwingHigh( 1, Price1, 1, 2 ) ;
if SwingPrice  <> -1 then 
	begin
		condition1 = TLDir <= 0 and SwingPrice >= SwingPrice1 + RetracePnts ;
		if condition1 then 			                            
			begin
				SaveSwing = true ;
				AddTL = true ;
				TLDir = 1 ;
			end 
		else 
		begin 
			condition1 = TLDir = 1 and SwingPrice >= SwingPrice1 ;
			if condition1 then 			                                
			begin
				SaveSwing = true ;
				UpdateTL = true ;
			end;
		end ;
	end 
else 
	begin
	SwingPrice = SwingLow( 1, price2, 1, 2 ) ;
	if SwingPrice <> -1 then 
		begin
			condition1 = TLDir >= 0 and SwingPrice <= SwingPrice1 - RetracePnts ;
			if condition1 then 				                            
			begin
				SaveSwing = true ;
				AddTL = true ;
				TLDir = -1 ;
			end 
			else 
			begin 
				condition1 = TLDir = -1 and SwingPrice <= SwingPrice1 ;
				if condition1 then 					                                
				begin
					SaveSwing = true;
					UpdateTL = true ;
				end ;
			end;
		end ;
	end ;

if SaveSwing then 
	                               
	begin
	SwingPrice1 = SwingPrice ;
	SwingDate = Date[1] ;
	SwingTime = Time[1] ;
	SaveSwing = false ;
	end ;
//added Updates text when you need to update the trend line. - Me

If UpdateTL = True then begin
SwingDistance = //absvalue(SwingPrice1 - SwingPrice1[1])*SwingMult;
		//absvalue(TL_GetBeginVal(var8)-swingprice1)*swingmult;
		absvalue(SwingStart - SwingPrice1)*SwingMult;
	If  PriceOrSwing = "Both" then begin
	if DecimalPlaces = 4 then
		Text_Setstring(value1,  numtostr(SwingPrice1,DecimalPlaces)+ NewLine + "    " + numtostr(swingdistance,0) );
	if DecimalPlaces = 2 then
		Text_Setstring(value1, numtostr(SwingPrice1,DecimalPlaces)+ NewLine + "  " + numtostr(swingdistance,0)) ;
	end;
	
	IF PriceOrSwing = "Price" then
		Text_SetString(value1, numtostr(SwingPrice1,DecimalPlaces));
	If PriceOrSwing = "Swing" then
		Text_SetString(value1, numtostr(swingdistance,0));
end;
	
//end 
If AddTL and Plotlines = false then
		SwingStart = SwingPrice1;
if AddTL and PlotLines = True then 
	                              
	begin
	SwingStart = SwingPrice1;
	var8 = TL_New( SwingDate, SwingTime, SwingPrice1, SwingDate[1], SwingTime[1], SwingPrice1[1] ) ;
	TL_SetExtLeft( var8, false ) ;
	TL_SetExtRight( var8, false ) ;
	TL_SetSize( var8, LineWidth ) ;
	TL_SetColor( var8, LineColor ) ;
	tl_setstyle(var8,LineStyle);
	AddTL = false ;
	end 
else if UpdateTL and PlotLines = True then 
	                                     
	begin
	TL_SetEnd( var8, SwingDate, SwingTime, SwingPrice1 ) ;
	UpdateTL = false ;
	end ;

//Text Prints
SwingDistance = absvalue(SwingPrice1 - SwingPrice1[1])*SwingMult;

if TLDir <> TLDir[1] and PriceOrSwing = "Price" then
value1 = text_new(SwingDate, SwingTime, SwingPrice1, numtostr(SwingPrice1,DecimalPlaces));

if TLDir <> TLDir[1] and PriceOrSwing = "Swing" then
value1 = text_new(SwingDate, SwingTime, SwingPrice1, numtostr(swingdistance,0));

if TLDir <> TLDir[1] and PriceOrSwing = "Both" then begin
if DecimalPlaces = 4 then
value1 = text_new(SwingDate, SwingTime, SwingPrice1, numtostr(SwingPrice1,DecimalPlaces)+ NewLine + "    " + numtostr(swingdistance,0) );
if DecimalPlaces = 2 then
value1 = text_new(SwingDate, SwingTime, SwingPrice1, numtostr(SwingPrice1,DecimalPlaces)+ NewLine + "  " + numtostr(swingdistance,0) );
end;

if TLDir = -1 then 
	text_setlocation(value1,SwingDate,SwingTime,SwingPrice1 - truerange*.25);

if TLDir = 1 then
	text_setlocation(value1,SwingDate,SwingTime,SwingPrice1 + truerange*.25);

//Text styling	
if value1 > 0 then begin
	text_setcolor(value1,color);
	text_setstyle(value1,2,2);
	text_setsize(value1,textsize);

end;	
		

//value2 = text_new(SwingDate, SwingTime, SwingPrice1 + .25*averagetruerange(10) , numtostr(SwingPrice1,4));
//print(SwingPrice:0:4," ", SwingPrice1:0:4, " ", SwingDate, " ", SwingTime, " ", TLDir, " ", SaveSwing, " ", AddTL, " ", UpdateTL, " ", var8);

Reply With Quote
 
  #9 (permalink)
Elite Member
Mumbai India
 
Futures Experience: None
Platform: TradeStation
Favorite Futures: Forex
 
Posts: 39 since Nov 2014
Thanks: 58 given, 10 received

Hi @treydog999 :

Were you finally able to get this to work? Will be extremely useful to have.

Thank you

Reply With Quote
 
  #10 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received



courier12 View Post
Hi @treydog999 :

Were you finally able to get this to work? Will be extremely useful to have.

Thank you

Sorry I never did figure it out. The plot and data seemed to be linked.

Reply With Quote

Reply



futures io > > > > > Problem with Zigzag that prints highs/lows and swing distance

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
new highs and new lows!!!!? tr3nt NinjaTrader Programming 9 August 12th, 2013 02:58 PM
HOD highs/lows of day dashover ThinkOrSwim 1 June 29th, 2013 01:16 PM
Converting code from Tradestation/ Plots Swing Point Highs/Lows wbtrader NinjaTrader Programming 4 May 14th, 2013 09:20 PM
zigzag indicator that can plot only highs or lows of each price swing rkost NinjaTrader 4 February 14th, 2013 01:04 PM
Accessing Zigzag swing highs/lows buylosellhi NinjaTrader Programming 3 April 27th, 2011 05:56 PM


All times are GMT -4. The time now is 05:05 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-18 in 0.16 seconds with 20 queries on phoenix via your IP 23.22.136.56