NexusFi: Find Your Edge


Home Menu

 





Can somebody clean up this code?


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one olobay with 4 posts (0 thanks)
    2. looks_two StratOpt with 4 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 3,692 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 10 posts
    2. attach_file 2 attachments




 
Search this Thread

Can somebody clean up this code?

  #1 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

Hi,

This code works but it is very sloppy. Can some EasyLanguage genius polish this up and code it properly? Right now it only plots when the end time has come. Also it's super slow when plot TodayOnly is false. It's supposed to look like this:




Thanks.

 
Code
Inputs: StartTime(0830), 
	 EndTime(0915), 
	 yHigh(93.09), 
	 yLow(90.96), 
	 yClose(92.96),
	 A_Val(.08),
	 C_Val(.13),
	 yHighLow_Color(darkgray),
	 yHighLow_Style(3),
	 yHighLow_LineSize(2),
	 yClose_Color(darkred),
	 yCLose_Style(3),
	 yClose_LineSize(2),
	 IB_Color(Red), 
	 IB_Style(2),  
	 IB_LineSize(0),
	 A_Color(Red), 
	 A_Style(2),  
	 A_LineSize(0),
	 C_Color(Cyan), 
	 C_Style(3),  
	 C_LineSize(1),
	 PP_Color(yellow), 
	 PP_Style(2),  
	 PP_LineSize(1),
	 Font_Name("Arial"),
	 Font_Size(9),
	 Text_Offset(60),
	 TodayOnly(True);

vars:  DPP(0), PV(0), PVR(0),
	HighDay(0), 
	LowDay(0),
	RangeToday(0), 
	LineId1(-1), 
	LineId2(-1), 
	LineId3(-1), 
	LineId4(-1), 
	LineId5(-1), 
	LineId6(-1), 
	LineId7(-1), 
	LineId8(-1), 
	LineId9(-1), 
	LineId10(-1),
	LineId11(-1), 
	LineId12(-1), 
	ID1(-1), 
	ID2(-1), 
	ID3(-1), 
	ID4(-1), 
	ID5(-1), 
	ID6(-1), 
	ID7(-1), 
	ID8(-1), 
	ID9(-1), 
	ID10(-1),
	ID11(-1),
	ID12(-1),
	ID1Text(-1),
	ID2Text(-1),
	ID3Text(-1),
	ID4Text(-1),
	ID5Text(-1),
	ID6Text(-1),
	ID7Text(-1),
	ID8Text(-1),
	ID9Text(-1),
	ID10Text(-1),
	ID11Text(-1),
	ID12Text(-1);
	
If Date <> Date[1] Then Begin   	// Initialize vars at max of ranges 
	HighDay = 0;
	LowDay = 99999;
End; 
 
If Time >= StartTime and Time <= EndTime Then Begin 
	// Get the high and low from the start time to end time 
	If H > HighDay Then HighDay = H; 
	If L < LowDay Then LowDay = L; 
End; 
 
If Time >= EndTime Then Begin 
	RangeToday = HighDay - LowDay;
	
	// Draw the OR High line
	If TodayOnly and LineId1 <> -1 and LineId1 <> ID1 Then TL_Delete(LineId1); 
	If TodayOnly and LineId1 <> -1 and LineId1 <> ID1 Then Text_Delete(LineId1); 
	If TodayOnly then LineId1 = ID1;
	ID1 = TL_New(Date, StartTime, HighDay, Date, Time, HighDay); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID1, True); 	 
	TL_SetEnd(ID1, Date, Time + Text_Offset, HighDay); 
	TL_SetColor(ID1, IB_Color);
	TL_SetStyle(ID1, IB_Style); 
	TL_SetSize(ID1, IB_LineSize); 
	ID1Text = Text_New(Date, Time + Text_Offset, HighDay, "OR  High"); 
	Text_SetStyle(ID1Text, 0, 1);	
	Text_SetColor(ID1Text, IB_Color); 
	Text_SetFontName(ID1Text, Font_Name); 
	Text_SetSize(ID1Text, Font_Size);
	Text_SetLocation(ID1Text, Date, Time + Text_Offset, HighDay);
 
	// Draw the OR Low Line
	If TodayOnly and LineId2 <> -1 and LineId2 <> ID2 Then TL_Delete(LineId2);
	If TodayOnly and LineId2 <> -1 and LineId2 <> ID2 Then Text_Delete(LineId2); 
	If TodayOnly Then LineId2 = Id2; 
	ID2 = TL_New(Date, StartTime, LowDay, Date, Time, LowDay);
	//If TodayOnly then Value1 = TL_SetExtRight(ID2, True); 
	TL_SetEnd(ID2, Date, Time + Text_Offset, LowDay);
	TL_SetColor(ID2, IB_Color); 
	TL_SetStyle(ID2, IB_Style); 
	TL_SetSize(ID2, IB_LineSize); 
	ID2Text = Text_New(Date, Time + Text_Offset, LowDay, "OR  Low");
	Text_SetStyle(ID2Text, 0, 1);	
	Text_SetColor(ID2Text, IB_Color); 
	Text_SetFontName(ID2Text, Font_Name);
	Text_SetSize(ID2Text, Font_Size);
	Text_SetLocation(ID2Text, Date, Time + Text_Offset, LowDay);	
	
	//Draw A Up Line
	If TodayOnly and LineId3 <> -1 and LineId3 <> ID3 Then TL_Delete(LineId3); 
	If TodayOnly and LineId3 <> -1 and LineId3 <> ID3 Then Text_Delete(LineId3);
	If TodayOnly then LineId3 = ID3;
	ID3 = TL_New(Date, StartTime, HighDay + A_Val, Date, Time, HighDay + A_Val); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID3, True); 	 
	TL_SetEnd(ID3, Date, Time + Text_Offset, HighDay + A_Val);
	TL_SetColor(ID3, A_Color); 
	TL_SetStyle(ID3, A_Style); 
	TL_SetSize(ID3, A_LineSize);
	ID3Text = Text_New(Date, Time + Text_Offset, HighDay + A_Val, "A  Up");
	Text_SetStyle(ID3Text, 0, 1);	
	Text_SetColor(ID3Text, IB_Color); 
	Text_SetFontName(ID3Text, Font_Name);
	Text_SetSize(ID3Text, Font_Size);
	Text_SetLocation(ID3Text, Date, Time + Text_Offset, HighDay + A_Val); 
	
	// Draw A Down Line
	If TodayOnly and LineId4 <> -1 and LineId4 <> ID4 Then TL_Delete(LineId4); 
	If TodayOnly and LineId4 <> -1 and LineId4 <> ID4 Then Text_Delete(LineId4); 
	If TodayOnly Then LineId4 = Id4; 
	ID4 = TL_New(Date, StartTime, LowDay - A_Val, Date, Time, LowDay - A_Val); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID4, True); 
	TL_SetEnd(ID4, Date, Time + Text_Offset, LowDay - A_Val);
	TL_SetColor(ID4, A_Color); 
	TL_SetStyle(ID4, A_Style); 
	TL_SetSize(ID4, A_LineSize); 
	ID4Text = Text_New(Date, Time + Text_Offset, LowDay - A_Val, "A  Down");
	Text_SetStyle(ID4Text, 0, 1);	
	Text_SetColor(ID4Text, IB_Color);
	Text_SetFontName(ID4Text, Font_Name); 
	Text_SetSize(ID4Text, Font_Size);
	Text_SetLocation(ID4Text, Date, Time + Text_Offset, LowDay - A_Val);
	
	//Draw C Up Line
	If TodayOnly and LineId5 <> -1 and LineId5 <> ID5 Then TL_Delete(LineId5); 
	If TodayOnly and LineId5 <> -1 and LineId5 <> ID5 Then Text_Delete(LineId5);
	If TodayOnly then LineId5 = ID5;
	ID5 = TL_New(Date, StartTime, HighDay + C_Val, Date, Time, HighDay + C_Val); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID5, True); 	 
	TL_SetEnd(ID5, Date, Time + Text_Offset, HighDay + C_Val);
	TL_SetColor(ID5, C_Color); 
	TL_SetStyle(ID5, C_Style); 
	TL_SetSize(ID5, C_LineSize);
	ID5Text = Text_New(Date, Time + Text_Offset, HighDay + C_Val, "C  Up");
	Text_SetStyle(ID5Text, 0, 1);	
	Text_SetColor(ID5Text, C_Color); 
	Text_SetFontName(ID5Text, Font_Name);	
	Text_SetSize(ID5Text, Font_Size);
	Text_SetLocation(ID5Text, Date, Time + Text_Offset, HighDay + C_Val);

	// Draw C Down Line
	If TodayOnly and LineId6 <> -1 and LineId6 <> ID6 Then TL_Delete(LineId6);
	If TodayOnly and LineId6 <> -1 and LineId6 <> ID6 Then Text_Delete(LineId6);  
	If TodayOnly Then LineId6 = Id6; 
	ID6 = TL_New(Date, StartTime, LowDay - C_Val, Date, Time, LowDay - C_Val); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID6, True); 
	TL_SetEnd(ID6, Date, Time + Text_Offset, LowDay - C_Val);
	TL_SetColor(ID6, C_Color); 
	TL_SetStyle(ID6, C_Style); 
	TL_SetSize(ID6, C_LineSize);
	ID6Text = Text_New(Date, Time + Text_Offset, LowDay - C_Val, "C  Down");
	Text_SetStyle(ID6Text, 0, 1);	
	Text_SetColor(ID6Text, C_Color); 
	Text_SetFontName(ID6Text, Font_Name);
	Text_SetSize(ID6Text, Font_Size);
	Text_SetLocation(ID6Text, Date, Time + Text_Offset, LowDay - C_Val);	

DPP = (yHigh + yLow + yClose ) /3; //Daily Pivot Point

	//Draw Daily Pivot Point Line
	If TodayOnly and LineId7 <> -1 and LineId7 <> ID7 Then TL_Delete(LineId7); 
	If TodayOnly and LineId7 <> -1 and LineId7 <> ID7 Then Text_Delete(LineId7); 
	If TodayOnly then LineId7 = ID7; 
	ID7 = TL_New(Date, StartTime, DPP, Date, Time, DPP); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID7, True); 	 
	TL_SetEnd(ID7, Date, Time + Text_Offset, DPP);
	TL_SetColor(ID7, PP_Color); 
	TL_SetStyle(ID7, PP_Style); 
	TL_SetSize(ID7, PP_LineSize);
	ID7Text = Text_New(Date, Time + Text_Offset, DPP, "DPP");
	Text_SetStyle(ID7Text, 0, 1);	
	Text_SetColor(ID7Text, PP_Color); 
	Text_SetFontName(ID7Text, Font_Name);
	Text_SetSize(ID7Text, Font_Size);
	Text_SetLocation(ID7Text, Date, Time + Text_Offset, DPP);

PV = (yHigh + yLow) /2;
PVR = (DPP - PV); //Pivot Range Value

	//Draw Pivot Range High Line
	If TodayOnly and LineId8 <> -1 and LineId8 <> ID8 Then TL_Delete(LineId8);
	If TodayOnly and LineId8 <> -1 and LineId8 <> ID8 Then Text_Delete(LineId8); 
	If TodayOnly then LineId8 = ID8; 
	ID8 = TL_New(Date, StartTime, DPP + PVR, Date, Time, DPP + PVR); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID8, True); 	 
	TL_SetEnd(ID8, Date, Time + Text_Offset, DPP + PVR);
	TL_SetColor(ID8, PP_Color); 
	TL_SetStyle(ID8, PP_Style); 
	TL_SetSize(ID8, PP_LineSize);
	ID8Text= Text_New(Date, Time + Text_Offset, DPP + PVR, "PVR  High");
	Text_SetStyle(ID8Text, 0, 1);	
	Text_SetColor(ID8Text, PP_Color); 
	Text_SetFontName(ID8Text, Font_Name);
	Text_SetSize(ID8Text, Font_Size);
	Text_SetLocation(ID8Text, Date, Time + Text_Offset, DPP + PVR);
	
	//Draw Pivot Range Low Line
	If TodayOnly and LineId9 <> -1 and LineId9 <> ID9 Then TL_Delete(LineId9);
	If TodayOnly and LineId9 <> -1 and LineId9 <> ID9 Then Text_Delete(LineId9); 
	If TodayOnly then LineId9 = ID9; 
	ID9 = TL_New(Date, StartTime, DPP - PVR, Date, Time, DPP - PVR); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID9, True); 	 
	TL_SetEnd(ID9, Date, Time + Text_Offset, DPP - PVR);
	TL_SetColor(ID9, PP_Color); 
	TL_SetStyle(ID9, PP_Style); 
	TL_SetSize(ID9, PP_LineSize);
	ID9Text= Text_New(Date, Time + Text_Offset, DPP - PVR, "PVR  Low");
	Text_SetStyle(ID9Text, 0, 1);	
	Text_SetColor(ID9Text, PP_Color); 
	Text_SetFontName(ID9Text, Font_Name);
	Text_SetSize(ID9Text, Font_Size);
	Text_SetLocation(ID9Text, Date, Time + Text_Offset, DPP - PVR);
	
	//Draw yHigh Line
	If TodayOnly and LineId10 <> -1 and LineId10 <> ID10 Then TL_Delete(LineId10); 
	If TodayOnly and LineId10 <> -1 and LineId10 <> ID10 Then Text_Delete(LineId10); 
	If TodayOnly then LineId10 = ID10; 
	ID10 = TL_New(Date, StartTime, yHigh, Date, Time, yHigh); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID10, True); 	 
	TL_SetEnd(ID10, Date, Time + Text_Offset, yHigh);
	TL_SetColor(ID10, yHighLow_Color); 
	TL_SetStyle(ID10, yHighLow_Style); 
	TL_SetSize(ID10, yHighLow_LineSize);
	ID10Text= Text_New(Date, Time + Text_Offset, yHigh, "Y  High");
	Text_SetStyle(ID10Text, 0, 1);	
	Text_SetColor(ID10Text, yHighLow_Color);
	Text_SetFontName(ID10Text, Font_Name);
	Text_SetSize(ID10Text, Font_Size);
	Text_SetLocation(ID10Text, Date, Time + Text_Offset, yHigh);
	
	//Draw yLow Line
	If TodayOnly and LineId11 <> -1 and LineId11 <> ID11 Then TL_Delete(LineId11); 
	If TodayOnly and LineId11 <> -1 and LineId11 <> ID11 Then Text_Delete(LineId11); 
	If TodayOnly then LineId11 = ID11; 
	ID11 = TL_New(Date, StartTime, yLow, Date, Time, yLow); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID11, True); 	 
	TL_SetEnd(ID11, Date, Time + Text_Offset, yLow);
	TL_SetColor(ID11, yHighLow_Color); 
	TL_SetStyle(ID11, yHighLow_Style); 
	TL_SetSize(ID11, yHighLow_LineSize);
	ID11Text= Text_New(Date, Time + Text_Offset, yLow, "Y  Low");
	Text_SetStyle(ID11Text, 0, 1);	
	Text_SetColor(ID11Text, yHighLow_Color);
	Text_SetFontName(ID11Text, Font_Name);
	Text_SetSize(ID11Text, Font_Size);
	Text_SetLocation(ID11Text, Date, Time + Text_Offset, yLow);
	
	//Draw yClose Line
	If TodayOnly and LineId12 <> -1 and LineId12 <> ID12 Then TL_Delete(LineId12); 
	If TodayOnly and LineId12 <> -1 and LineId12 <> ID12 Then Text_Delete(LineId12); 
	If TodayOnly then LineId12 = ID12;
	ID12 = TL_New(Date, StartTime, yClose, Date, Time, yClose); 
	//If TodayOnly then Value1 = TL_SetExtRight(ID12, True); 	 
	TL_SetEnd(ID12, Date, Time + Text_Offset, yClose);
	TL_SetColor(ID12, yClose_Color); 
	TL_SetStyle(ID12, yClose_Style); 
	TL_SetSize(ID12, yClose_LineSize);
	ID12Text= Text_New(Date, Time + Text_Offset, yClose, "Y  Close");
	Text_SetStyle(ID12Text, 0, 1);	
	Text_SetColor(ID12Text, yClose_Color);
	Text_SetFontName(ID12Text, Font_Name);
	Text_SetSize(ID12Text, Font_Size);
	Text_SetLocation(ID12Text, Date, Time + Text_Offset, yClose);

end;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7


Text_SetFontName ??
Text_SetSize ??

These are not normal TS Reserved words up through build 25 of 9.1

Also, it is super helpful to programmers to have a project outline of what the indicator is required to do.

Reply With Quote
  #4 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

It's for MultiCharts instead of Tradestation. The indicator is supposed to plot the opening range for a desired span of time which can be input in the input section of the indicator.

Then it's supposed to plot two more lines at a desired value above and below the opening range, also indicated in the input section of the indicator.

Then it's supposed to plot another 2 lines at a different desired value above and below the opening range, again indicated in the input section.

Finally, using the previous days high, low and close, it's supposed to plot 3 pivot lines, the daily pivot, the pivot high and the pivot low.

The other inputs are just for formatting of the lines and text. The indicator basically plots Mark Fisher's ACD method.

Started this thread Reply With Quote
  #5 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

I am new here so not sure why it is that people post into the TradeStation forum for code for MultiCharts when there is a MultiCharts section ?

I know that code can port, but unless a person has both TradeStation and MultiCharts, which I do, then they would be of limited usage to only code that can port and then the programmer wouldn't be able to check and verify the results of their code sets

Note to those who use TradeStation:
You can change font sizes and types by using the new Font class within TradeStation

Reply With Quote
  #6 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011

MultiCharts users post here because when you click on the link with the arrow, you end up here. I only have MC.


Started this thread Reply With Quote
  #7 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

Ok so the forum pushes you to here as a hyperlink. Not sure why that would be other than the code porting ability, but it is what it is. I had another person requesting help and I provided some of my valuable time to write code that in the end the person couldn't use because they were actually needing it for MultiCharts. Outside of being of some help to some other person unassociated with the topic who is actually needing similar solution in EasyLanguage then it seems to be an inapproriate use of my time to provide any help at all here.

Reply With Quote
  #8 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,603


StratOpt View Post
Ok so the forum pushes you to here as a hyperlink. Not sure why that would be other than the code porting ability, but it is what it is. I had another person requesting help and I provided some of my valuable time to write code that in the end the person couldn't use because they were actually needing it for MultiCharts. Outside of being of some help to some other person unassociated with the topic who is actually needing similar solution in EasyLanguage then it seems to be an inapproriate use of my time to provide any help at all here.

Because we don't need two EasyLanguage forums. EasyLanguage is TradeStation's so it falls under their name on the forum.

Look at the persons profile which is to the left of their post. It will clearly say what platform they are using.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

I suppose that I don't consider MultiCharts language as EasyLanguage is the confusion. I treat the two platforms as separate from one another.

Reply With Quote
  #10 (permalink)
 olobay 
Montreal
 
Experience: Intermediate
Platform: MultiCharts
Broker: DeepDiscountTrading.com
Trading: CL
Posts: 364 since Jul 2011


Can anybody help?

Started this thread Reply With Quote




Last Updated on January 11, 2014


© 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 - Downloads - Top
no new posts